first commit

This commit is contained in:
Boris
2024-01-15 20:14:10 +00:00
commit 8c81ee28b7
3106 changed files with 474415 additions and 0 deletions

View File

@@ -0,0 +1,128 @@
## Lecture 1 (13:00) - Conceptual Modelling
### Role of Conceptual Modelling
- Real world problem -> Conceptual Model Data -> Logical Data Model -> Physical Model (DBMS)
- Identify important concepts and data needs, creating a conceptual model.
- Many different ways to get to the same solution.
- Iterative process - if one method does not work, it can be revised.
### Conceptual Data Model
- Abstract view of situation.
- Identifies important elements and relationships between them. (ex. Library: Books, Members, ~~Carpets~~)
- Human interact-able, not computer terms.
- Implementation Independent.
- Useful for client brief.
### Reasons for Using ER Modelling
- Simpler and easier to understand than database tables
- Helps discussions with clients and colleagues
- Allows for segmentation of work.
- Modelling real world solution
- Designing DB tables
- Most large organisations will require it
### Obtaining an ER Model
- Given a spec, you need to identify:
- entities - 'things' with physical or conceptual existence
- relationships
- attributes
- constraints or assumptions
#### Example
Departments control many projects and each department has many employees. Each employee works on only one project at a time. A projects start date must be before the projects target completion date. Each employee has an NI number, name and address
Entities:
- departments
- projects
- employees
Relationships:
- **control** between departments and projects
- **has between** departments and employees
- **works on** between employees and projects
Attributes:
- startdate
- completiondate
- ninumber
- name
- address
Constraints:
- Start date must be before the target completion date
### ER Diagram
![](Pasted%20image%2020231017132317.png)
- Many different notations
- One is "crows foot":
![](Pasted%20image%2020231017132357.png)
![](Pasted%20image%2020231017133438.png)
![](Pasted%20image%2020231017133451.png)
## Lecture 3 (16:00)
1. Generate a list of the ages of ATMs whose security level is normal. The list should be in descending order.
```sql
SELECT age
FROM atm
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.
```sql
SELECT DISTINCT name
FROM bank, branch
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”.
```sql
SELECT AVG(age) AS "Average Age"
FROM atm
WHERE security-level = "low" OR security-level = "normal";
```
4. 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.
```sql
INSERT INTO atm
VALUES ("atm05", "high", "0", "T1");
```
6. 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.
```sql
UPDATE branch
SET address = "Salford";
```
1) Bank LEFT OUTER JOIN Branch
```sql
SELECT *
FROM bank
INNER JOIN
```