lint all files
This commit is contained in:
@@ -28,4 +28,4 @@ Challenge Question
|
||||
There are just five orders in which both the customer and employee come from the same
|
||||
city. These five orders involve just two cities. Write an SQL query which lists the names
|
||||
of these cities.
|
||||

|
||||

|
||||
|
@@ -75,7 +75,7 @@ WHERE security-level = "normal"
|
||||
ORDER BY age DESC;
|
||||
```
|
||||
|
||||
2. List the name of each bank which has a branch whose address starts with the word Eccles. The list should not include any duplicates.
|
||||
1. List the name of each bank which has a branch whose address starts with the word Eccles. The list should not include any duplicates.
|
||||
|
||||
```sql
|
||||
SELECT DISTINCT name
|
||||
@@ -84,7 +84,7 @@ WHERE Bank.bankID = Branch.bankID
|
||||
AND address LIKE "Eccles*";
|
||||
```
|
||||
|
||||
3. Calculate the average age of the ATMs with low or normal levels of security. Name the results column “Average age”.
|
||||
1. Calculate the average age of the ATMs with low or normal levels of security. Name the results column “Average age”.
|
||||
|
||||
```sql
|
||||
SELECT AVG(age) AS "Average Age"
|
||||
@@ -92,37 +92,38 @@ FROM atm
|
||||
WHERE security-level = "low" OR security-level = "normal";
|
||||
```
|
||||
|
||||
4. Remove the tuple from the relation ATM whose identifier is atm04.
|
||||
1. Remove the tuple from the relation ATM whose identifier is atm04.
|
||||
|
||||
```sql
|
||||
DELETE FROM atm
|
||||
WHERE atmID = "atm04";
|
||||
```
|
||||
|
||||
5. Add a row for an ATM, whose atmID is atm05, whose security level is high and which is located at branch T1.
|
||||
1. Add a row for an ATM, whose atmID is atm05, whose security level is high and which is located at branch T1.
|
||||
|
||||
```sql
|
||||
INSERT INTO atm
|
||||
VALUES ("atm05", "high", "0", "T1");
|
||||
```
|
||||
|
||||
6. Add an attribute called telephone number to the relation Branch.
|
||||
1. Add an attribute called telephone number to the relation Branch.
|
||||
|
||||
```sql
|
||||
ALTER TABLE branch
|
||||
ADD telephone CHAR(15)
|
||||
```
|
||||
|
||||
7. Set the address of every branch to the value Salford.
|
||||
1. Set the address of every branch to the value Salford.
|
||||
|
||||
```sql
|
||||
UPDATE branch
|
||||
SET address = "Salford";
|
||||
```
|
||||
|
||||
1) Bank LEFT OUTER JOIN Branch
|
||||
1. Bank LEFT OUTER JOIN Branch
|
||||
|
||||
```sql
|
||||
SELECT *
|
||||
FROM bank
|
||||
INNER JOIN
|
||||
```
|
||||
```
|
||||
|
@@ -148,6 +148,7 @@ A car must have exactly one owner.
|
||||
### Exercise 1
|
||||
|
||||
#### Part 1
|
||||
|
||||
Project -o---|-/\\- Order
|
||||
\[1:M] \[o:m] Relationship
|
||||
|
||||
@@ -155,6 +156,7 @@ project(proj#, name, start-date, end-date)
|
||||
order(order#, date, inquiry, proj#\*)
|
||||
|
||||
#### Part 2
|
||||
|
||||
Supplier -/\\-o---o-/\\- Part
|
||||
\[M:M] \[o:o] Relationship
|
||||
|
||||
@@ -165,6 +167,7 @@ orderList(supplier#\*, part#\*)
|
||||
- We must create a new composite table to contain the relation, since we cannot sustain the principles of foreign keys.
|
||||
|
||||
#### Part 3
|
||||
|
||||
Staff -/\\-|---|- Department
|
||||
\[M:1] \[m:m] Relationship
|
||||
|
||||
@@ -174,6 +177,7 @@ department(dept-id, name, location)
|
||||
- We would create dept-id as a foreign key in the staff table, as multiple values wont occur, and staff must be a part of a department in this scenario.
|
||||
|
||||
#### Part 4
|
||||
|
||||
Manager -|---|- Project
|
||||
\[1:1] \[m:m] Relationship
|
||||
|
||||
@@ -183,6 +187,7 @@ project(proj-id, name, start-date, end-date)
|
||||
- We could use either primary key for the alternate table's foreign key, since they are both mandatory and 1:1, so there would be no multiple values nor would there be null values.
|
||||
|
||||
#### Part 5
|
||||
|
||||
Manager -|---|-/\\- Team -|---|-/\\- Player
|
||||
\[1:M] \[m:m] (Both) Relationship
|
||||
|
||||
@@ -193,14 +198,16 @@ player(player-id, name, address, tel-no, team-name*)
|
||||
## Tutorial 2 (14:00)
|
||||
|
||||
#### Entities & Attributes
|
||||
|
||||
| Entities | Attributes |
|
||||
|----------|------------|
|
||||
| Regional Office | *regioncode*, name, location |
|
||||
| Regional Office | *regioncode*, name, location |
|
||||
| Branch | *branch_no*, institution |
|
||||
| Member | *mem_no*, name, age, type |
|
||||
| Role | *role_id*, level, role |
|
||||
| Role | *role_id*, level, role |
|
||||
|
||||
#### Relations
|
||||
|
||||
Role - \[1:M]\[m:o] - Member
|
||||
Member - \[M:1]\[o:m] - Branch
|
||||
Member - \[M:1]\[o:m] - Branch
|
||||
Branch - \[M:1]\[m:m] - Region
|
||||
|
@@ -92,4 +92,4 @@ WHERE value > (
|
||||
|
||||
3. List names of the products whose number of units in stock is less than the average number of units in stock and whose number of units on order is less than the average number of units on order.
|
||||
|
||||

|
||||

|
||||
|
Reference in New Issue
Block a user