Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Relationships Entities take part in relationships. We can often identify relationships from verbs or verb phrases. For example – you are attending this.

Similar presentations


Presentation on theme: "1 Relationships Entities take part in relationships. We can often identify relationships from verbs or verb phrases. For example – you are attending this."— Presentation transcript:

1 1 Relationships Entities take part in relationships. We can often identify relationships from verbs or verb phrases. For example – you are attending this lecture, – I am giving the lecture. As with entities, we classify relationships according to relationship-types: – A student attends a lecture; – A lecturer gives a lecture.

2 2 Relationship Connectivity Constraints on the mapping of the associated entities in the relationship. Denoted by variables between the related entities. Generally, values for connectivity are expressed as “one” or “many” NameSSN EmployeeDepartment NameBudget work 1N

3 Types of Binary Relationship Sets Many-to-Many 1-to-11-to ManyMany-to-1

4 Degrees of a Relationship Man Man Woman Woman Customer Customer Order Order Course Course Subject Subject One-to-one (1:1) One-to-many (1:n) Many-to-many (n:m) NOTE: Every many to many relationship consists of two one to many relationships working in opposite directions 1M 1 1 MM

5 5 Connectivity DepartmentManager has 11 DepartmentProject has N1 EmployeeProject works on NM one-to-one one-to-many many-to-many

6 6 Simple E-R Diagram Example Student Lecture Lecturer E-R diagram example gives attend M 1 M N

7 7 Relationship Participation Two types  Total (representing in the ER as double lines)  Partial representing in the ER as one line) Principally we are interested in the question, “Does every entity of a some type have to take part in a relationship of a given type?” For example, it might be considered true that:  Every lecture has to be given by a lecturer (total)  Every lecturer has to give at least one lecture (total)  Every lecture has to be attended by at least one student (total)  Not every student has to attend a lecture (partial)

8 8 E-R Diagram We extend the relationship diagram to include participation: Student Lecture Lecturer E-R diagram extended to show relationship degrees and participations. gives attend s M 1 M N

9 Chapter 3-9 A RECURSIVE RELATIONSHIP SUPERVISION e 1 e 2 e 3 e 4 e 5 e 6 e 7 EMPLOYEE r1r2r3r4r5r6r1r2r3r4r5r6 SUPERVISION © The Benjamin/Cummings Publishing Company, Inc. 1994, Elmasri/Navathe, Fundamentals of Database Systems, Second Edition

10 10 Recursive Relationships Employee id name address phone number Manages An entity set can participate more than once in a relationship In this case, we add a description of the role to the ER- diagram manager worker

11 Relationships of Higher Degree Relationship types of degree 2 are called binary Relationship types of degree 3 are called ternary and of degree n are called n-ary In general, an n-ary relationship is not equivalent to n-binary relationships

12 An example using a ternary relationship Each VENDOR can supply many PARTs to any number of WAREHOUSES, but need not supply any parts Each PART can be supplied by any number of VENDORs to more than one WAREHOUSE, but each part must be supplied by at least one vendor to a warehouse Each WAREHOUSE can be supplied with any number of PARTS from more than one VENDOR, but each warehouse must be supplied with at least one part

13

14 14 ER example 2 Football coach needs to collect information about his team. The coach requires information on: Players Player statistics Games Sales

15 15 Team Entities & Attributes Players - statistics, name, start date, end date Games - date, opponent, result Sales - date, tickets, merchandise what the Entities & Attributes ?????????????

16 Entities & Attributes Players Sales Start dateEnd date StatisticsName ticketsmerchandise Games opponentdateresult

17 17 Team Relationships Identify the relationships. The player statistics are recorded at each game so the player and game entities are related.

18 Team Relationships Players Games N play 1 For each game, we have multiple players so the relationship is one-to-many

19 19 Team Relationships Identify the relationships. The sales are generated at each game so the sales and games are related. GamesSales generates 11

20 Team Relationships GamesSales generates 11 We have only 1 set of sales numbers for each game, one-to- one.

21 21 Team ER Diagram Players Games Sales play generates N Start dateEnd dateStatistics Name ticketsmerchandise opponentdateresult

22 22 Useful Information Attribute or Entity-type? To decide whether a concept be modelled as an attribute or an entity-type: – Do we wish to store any information about this concept (other than an identifying name)? – Is it single-valued?

23 23 Determining components of an E-R Diagram From a description of the Universe of Discourse (UoD): Underline nouns and noun-phrases – These are candidates for entity-types Underline verbs and verb-phrases – These are candidates for relationship-types Check each entity- and relationship-type for relevance. Remove any for which there is only one instance.


Download ppt "1 Relationships Entities take part in relationships. We can often identify relationships from verbs or verb phrases. For example – you are attending this."

Similar presentations


Ads by Google