Presentation is loading. Please wait.

Presentation is loading. Please wait.

CM2020: Introduction to Database Systems Conceptual Modelling with The Entity Relationship Model Database Systems 4 th edition Connolly and Begg Chapter.

Similar presentations


Presentation on theme: "CM2020: Introduction to Database Systems Conceptual Modelling with The Entity Relationship Model Database Systems 4 th edition Connolly and Begg Chapter."— Presentation transcript:

1 CM2020: Introduction to Database Systems Conceptual Modelling with The Entity Relationship Model Database Systems 4 th edition Connolly and Begg Chapter 11 Nirmalie Wiratunga

2 Aim of Lecture Outline the steps involved in designing a database Explain the first phase: Conceptual Modelling Study a particular conceptual model: –Entity Relationship (ER) Model By the end you should be able to – Explain what conceptual design is, and how it is used – Represent a real-world situation as an ER Model – Understand an ER model constructed by someone else

3 Role of Conceptual Modelling within the design process Real-World Organisation / Problem Logical Data ModelConceptual Data Model Physical Model (via DBMS) Identify key concepts and data needs Create a conceptual model Convert model to structures required by database (relational, object- oriented, etc.) Implement using a DBMS (MSA, ORACLE): create tables, add data, constraints, etc.

4 –Use human understandable terms, not computer terms Tables, Combo Boxes, Foreign Keys… The Conceptual Data Model –Implementation independent –One form is the Entity Relationship (ER) model –Basis for the next step: the logical model Abstract view of situation – Identify important entities and relationships between them Library: Books, Members, Carpets Member borrows Book

5 Simplicity of ER modelling Staff StaffId Name Title WorksOn StaffId ProjectId Project ProjectId Name StartDate 1 1 ER diagram Tables Suppose we wish to record details of staff working on project. ER diagrams are simpler than the table representation Works_on Project Staff

6 Purpose of ER modelling? ER model is simpler and easier to understand –Helps discussions with customers and fellow-workers Separates –Modelling the real-world problem situation –Designing the DB tables for a DBMS (e.g. MSA) Most large organisations will require ER Modelling

7 Contents Components of an ER model Entity –Entity sets and descriptions Relationship –Functional and membership class descriptions Constraints and Assumptions Putting it all together with example ER Models Advance concepts –Inheritance –Recursion –Ternary relationships

8 Components of an ER Model The ER Model consists of four items: 1. An ER Diagram (using Bachman Notation) - graphical representation of the entities and the relationships between them 2. A formal description of each entity in terms of its attributes and identifiers 3. Descriptions of the meaning of relationships 4. Descriptions of any constraints on the system and of any assumptions made Note: the completion of an ER Model is iterative and unlikely to be successful first time round

9 Makes Driver TripVehicle Incurs Includes Uses Food Processor Expense Maintenance Engineer Qualification Holds Customer Stop Delivers Receives Food Processor Type Has Undergoes Visits Date-obtained Performs Staff Example of a realistic ER diagram

10 How do you obtain an ER Model ? Given a specification, you need to identify the following concepts: –Entities: things with physical or conceptual existence - usually nouns –Relationships: between entities - usually verbs –Attributes: of each entities and sometimes relationships –any constraints or assumptions

11 Identify ER Concepts in a Specification start date completion date 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. Entities: departments, projects, employees Relationships: control - between departments and projects has - between departments and employees works_on - between employees and projects Attributes: Start date, completion date for project. NI number, name, address for employee. Constraints: A projects start date must be before its target completion date. Attribute Relationship Entity Attribute Relationship

12 Contents Components of an ER model Entity –Entity sets and descriptions Relationship –Functional and membership class descriptions Constraints and Assumptions Putting it all together with example ER Models Advance concepts –Inheritance –Recursion –Ternary relationships

13 Entity Definition –real-world object distinguishable from other objects and described using a common set of attributes. –Diagrammatically shown as Entity Set: a collection of similar entities –E.g. all employers, all students –the set tends to have the same number of attributes –must have a primary key entity-name

14 Entity Examples Delivery database Drivers Customers Deliveries Invoice College registration database Student Instructor Classroom Course Restaurant database Menu Recipe Ingredient Order Personal Music database ?

15 Descriptions of entities Properties of entities are called attributes –Simple or composite e.g. name (firstname, surname) –Identifiers: One or more unique attributes are chosen as an identifier for the entity (a.k.a. primary key) –Single or multi-valued e.g. hobbies {cycling,reading,music} –Derived e.g. TotalCost (UnitCost * Quantity) Entity description = Entity name + identifier + other attributes Entity Set: the set of entity descriptions

16 Entity Sets Supervisor Student Supervisor(staffID, name, jobTitle, address) Student(studentID, name, address, staffId*) Entity Sets do NOT include foreign keys at the conceptual modelling stage Other Examples of Entity Sets: Driver(driver#, first-name, surname, address, #points) Exam(module#, student#, grade)

17 Contents Components of an ER model Entity –Entity sets and descriptions Relationship –Functional and membership class descriptions Constraints and Assumptions Putting it all together with example ER Models Advance concepts –Inheritance –Recursion –Ternary relationships

18 Relationships An association among entities. –Supervisor supervises student Relationships are described in terms of their –Functionality –Membership Class –Attributes SupervisorStudent supervises

19 Relationship: Functionality Each supervisor can supervise many students, but each student has only one supervisor Supervisor Student supervises Functionality answers two questions: Can the supervisor have more than one student? Yes Can the student have more than one supervisor? No So were interested in the MAX number of each entity involved: is it 1 or many?

20 Functionality Types 1- to -11- to manymany to -1many to many Functionality types are based on different mappings between entities

21 Relationship: Membership Class A supervisor does not have to supervise any students. A student has to have a supervisor. The membership class answers two questions: Must the supervisor have at least one student? No Must the student have at least one supervisor? Yes So were interested in the MIN number of each entity involved: is it 0 or 1? Where, 0 means optional and 1 means mandatory Supervisor Student supervises Supervisors participation in supervision is optional Students participation in supervision is mandatory

22 A supervisor may supervise no students, or may supervise many students A student must have at least one supervisor, and not more than one supervisor Combining Functionality and Membership Supervisor Student supervises

23 Relationship: Example 1 Castle School High School Hill School Hamilton Stevens Walters TeacherSchool employ Brian Paul Every school must employ atleast one or more Teachers Every teacher must work in at most one school

24 Castle School High School Hill School Hamilton Stevens Walters TeacherSchool employ Brian Paul Every school must employ one or more Teachers Every teacher may work in zero or one school - Paul does not work in any school Relationship: Example 2

25 Relationship: Example 3 Castle School High School Hill School Hamilton Stevens Walters TeacherSchool employ Brian Paul Schools can employ many teachers, but some schools have yet to recruit. Some teachers do not work whilst others work in a school.

26 Relationship: Example 4 Castle School High School Hill School Hamilton Stevens Walters TeacherSchool employ Brian Paul Schools can employ many teachers, but some schools have yet to recruit All teachers must work in a school.

27 Description of Relationships Supervisor Student supervises Functionality: one to many, written [1:M] many to many, written [M:N] one to one, written [1:1] Membership class: optional to mandatory, written [o:m] Description of relationship is therefore: Supervises: Supervisor supervises student [1:M] [o:m]

28 Description of Relationships with Attributes works_in Assistant Lab hours Assistant works in Lab for many hours per week. works_in(hours): assistant works in lab [M:N] [o:m] Description of relationship

29 Contents Components of an ER model Entity –Entity sets and descriptions Relationship –Functional and membership class descriptions Constraints and Assumptions Putting it all together with example ER Models Advance concepts –Inheritance –Recursion –Ternary relationships

30 Descriptions of Constraints / Assumptions Examples of constraints: –#points on drivers license must be less than 11 –pickup_date must be before delivery_date –Driver title must be Mr, Mrs or Ms Examples of Assumptions –Typically involve assumptions made about a relationships membership and/or functionality

31 Contents Components of an ER model Entity –Entity sets and descriptions Relationship –Functional and membership class descriptions Constraints and Assumptions Putting it all together with example ER Models Advance concepts –Inheritance –Recursion –Ternary relationships

32 Example ER model: a staff project management system Supervisor Student supervises Supervisor(StaffID, Name, JobTitle, Address) Student(StudentID, Name, Address, date_enrolled, completion_date, DOB) Entity Sets Supervises: Supervisor supervises student [1:M] [o:m] Relationships Constraints/Assumptions Students date_enrolled must be before completion_date ER diagram

33 Example ER model: A library System Entities –Book(ISBN, title, author,…) –Member(MemberID, name, address, phone#, …) Relationships –Borrows(return-date) – members borrow books [1:M][o:o] Constraints and assumptions: –A member can borrow up to 6 books at once –Each book can be borrowed by at most one member ER diagram return-date borrows Member Book

34 Contents Components of an ER model Entity –Entity sets and descriptions Relationship –Functional and membership class descriptions Constraints and Assumptions Putting it all together with example ER Models Advance concepts –Inheritance –Recursion –Ternary relationships

35 Advanced Concepts of ER diagrams ER Diagram, which is part of the ER Model, can become more complex i.e., we may have the following: –Entity Subsets and Supersets –Complex Relationships Involuted or Recursive Relationships Ternary Relationships

36 Entity subsets and supersets makes Driver Trip Maintenance Engineer performs Staff Branch has many Staff. Engineers perform many maintenance tasks. Drivers make many trips. Branch has

37 Unusual Relationships Recursive Employee manages Ternary Programmer Project Site works on Convert works on into an entity

38 Summary ER Modelling –A conceptual design technique –Is independent of the type of logical model / database youre going to transform it into –Contains entities, attributes, relationships and constraints/assumptions –ER Diagram is a graphical representation using the Bachman notation

39 Dark Lord More examples of Bachman Notation A principal must govern exactly one university A university cant have more than one principal, and may have no principal Description: Principal governs university [1:1] [m:o] Principal University governs commands Minion A dark lord may have no minions, or he may have many minions. A minion must have exactly one Dark Lord Description: Dark Lord commands minion: [1:M] [o:m]

40 Identify Entities and Attributes code number namelocation We need a database to track the movement of stock items. Each item has a code number and comes from a particular supplier. Each item can be used on one of many platforms. Each platform has a name and location. id code, name, address phone number Each supplier has an id code, name, address and phone number. latitude, longitude, sea area name Each location has a latitude, longitude, and sea area name. Attribute Relationship Entity Attribute Relationship


Download ppt "CM2020: Introduction to Database Systems Conceptual Modelling with The Entity Relationship Model Database Systems 4 th edition Connolly and Begg Chapter."

Similar presentations


Ads by Google