3.2 KiB
3.2 KiB
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.
- Identifies important elements and relationships between them. (ex. Library: Books, Members,
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 project’s start date must be before the project’s 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
Lecture 3 (16:00)
- Generate a list of the ages of ATMs whose security level is normal. The list should be in descending order.
SELECT age
FROM atm
WHERE security-level = "normal"
ORDER BY age DESC;
- List the name of each bank which has a branch whose address starts with the word Eccles. The list should not include any duplicates.
SELECT DISTINCT name
FROM bank, branch
WHERE Bank.bankID = Branch.bankID
AND address LIKE "Eccles*";
- Calculate the average age of the ATMs with low or normal levels of security. Name the results column “Average age”.
SELECT AVG(age) AS "Average Age"
FROM atm
WHERE security-level = "low" OR security-level = "normal";
- Remove the tuple from the relation ATM whose identifier is atm04.
DELETE FROM atm
WHERE atmID = "atm04";
- Add a row for an ATM, whose atmID is atm05, whose security level is high and which is located at branch T1.
INSERT INTO atm
VALUES ("atm05", "high", "0", "T1");
- Add an attribute called telephone number to the relation Branch.
ALTER TABLE branch
ADD telephone CHAR(15)
- Set the address of every branch to the value Salford.
UPDATE branch
SET address = "Salford";
- Bank LEFT OUTER JOIN Branch
SELECT *
FROM bank
INNER JOIN