Presentation is loading. Please wait.

Presentation is loading. Please wait.

MIS 3053 Database Design & Applications The University of Tulsa Professor: Akhilesh Bajaj ER Model Lecture 2 © Akhilesh Bajaj, 2000, 2002, 2003, 2004,

Similar presentations


Presentation on theme: "MIS 3053 Database Design & Applications The University of Tulsa Professor: Akhilesh Bajaj ER Model Lecture 2 © Akhilesh Bajaj, 2000, 2002, 2003, 2004,"— Presentation transcript:

1 MIS 3053 Database Design & Applications The University of Tulsa Professor: Akhilesh Bajaj ER Model Lecture 2 © Akhilesh Bajaj, 2000, 2002, 2003, 2004, 2006, 2010. All Rights Reserved.

2 Review of Lecture 1 Entities and entity sets Attributes (simple / composite, single valued / multivalued, null valued, derived) Relationships and relationship sets Attributes of relationship sets Degree of relationship sets Cardinality of relationship sets

3 Goals Today Review concepts we did in the previous class Learn about existence dependencies (weak entity sets) Learn about keys of entity sets

4 Very Important Facts -We never ever,ever repeat anything in the ER diagram. -If we identify a “bunch of objects” each described by the same set of properties (or attributes) then it’s most likely an entity set -If it’s an entity set it will have a primary key. -If it’s a relationship set it will not have its own primary key. It may have some attributes, but it’s really just a “bunch of links” between objects in boxes (entity sets). -For cardinalities, we say “For each object on the other side of the diamond, how many minimum objects on this side is it linked to? And how many maximum?” -Ternary relationships are rare, and may lead to data redundancy. Be careful!

5 Existence Dependencies If the existence of entity x depends on entity y, then if y is deleted, x should also be deleted. E.g., the entity set course_sections is existence dependent on the entity set courses. So, each course_section is dependent on one and only one course for its existence. Thus, this section Fall2011A is existence dependent on the course MIS3053 (if that is how a course is defined). The course can have many sections Other examples of existence dependencies? In the above example, we say that course_sections is the weak entity set, while courses is the corresponding strong entity set. Another way to think: If we talk about the weak entity, we always HAVE to refer to the strong entity. If we say section Fall2011A, the question is: which course are we talking about? In a bank, if we say transaction id3, the question is: which account?

6 Rules for Determining if a Weak Entity Set is Appropriate 1. We cannot identify the weak entity without the primary key of the Strong entity 2. Delete the Strong Entity from its set ==> weak entities linked to that strong entity must be deleted 3. Each weak entity can have one and only 1 strong entity in the strong entity set. 4. A weak entity cannot switch from one strong entity to another in the strong entity set. ALL 4 of these points should be true.

7 Existence Dependencies The relationship set between a weak entity set and the corresponding strong entity set is shown differently in an ER diagram. The weak entity set is shown thus: The cardinality of the relationship set is always: Strong entity set Relationship set showing existence dependency Weak entity set 0:n OR 1:n1:1 Double Diamond Shows Existence Dependency

8 Example ER diagram of Professors, Students, Courses and Course_sections. Drawing ER diagrams with Weak Entity Sets

9 Keys are used to uniquely distinguish entities in an entity set and relationships in a relationship set. Keys are attribute(s) that distinguish entities and relationships. In the ER model, we shall only do primary keys. A primary key of an entity set is a set of attributes (usually one attribute) that uniquely distinguishes each entity in the entity set, such that no subset of this set of attributes is also a key. E.g., student_id can be designated the primary key of students. The only subset of this (set of) attributes is student_id itself. Other Examples? Keys in the ER model

10 A weak entity set has an attribute (or a set of attributes) that is a unique identifier. The unique identifier of the weak entity set is combined with the primary key of the corresponding strong entity set, to form the primary key of the weak entity set. E.g., the unique identifier of course_section is the section_id. There may be several sections with the same section_id (say, Fall2010A). To identify each section, we also need to know which course it belongs to. This information is got from the primary key value of the course which is the strong entity for the section. We shall not consider keys of relationship sets in this course. Keys in the ER model

11 A more complete university example. Drawing ER diagrams

12 Is it a real-world object? Is it likely to be in relationships with other objects? Is it described by a set of properties? E.g., Should telephone be a telephone_number attribute or an entity set Telephones, described by telephone_ number (and maybe other attributes like phone_type)? Design Issues: Entity Sets or Attributes?

13 One strategy is to model actions (verbs) as relationships and nouns as entities. E.g., Professors teach Courses. Design Issues: Entity Sets or Relationship Sets? Noun Entity Set Verb relationship set Noun Entity Set Another strategy is to ask yourself: Is this a real-world object, or does it represent a relationship between 2 real-world objects? E.g., Loan in a bank could be an entity set or a relationship set between customers and branches.


Download ppt "MIS 3053 Database Design & Applications The University of Tulsa Professor: Akhilesh Bajaj ER Model Lecture 2 © Akhilesh Bajaj, 2000, 2002, 2003, 2004,"

Similar presentations


Ads by Google