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 1 © 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 1 © Akhilesh Bajaj, 2000, 2002, 2003, 2004."— Presentation transcript:

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

2 What is a Data Model? It is a collection of conceptual tools for describing data, data relationships, data semantics and consistency constraints. Essentially answers the following questions: - What is data? - How are the data related to each other? - How can we query the data and change it? - How do we ensure that the data represents a correct view of the real world (data integrity)? Examples of data models include the relational model, the ER model, the network model and the hierarchical model. The network and hierarchical models are found on older mainframe systems (usually in large organizations).

3 Where Does the ER Model fit in? In the 1960’s and early 1970’s, the network & hierarchical models were used. In 1970-71 the relational model was proposed as an alternative data model. In 1976, the ER model was proposed, as another data model. Today, most database management systems (DBMS) use the relational model. The ER model is very useful in getting requirements from end-users. Many consulting firms are starting to use it. A “standard” database development methodology, is to capture user requirements in the ER model, and then map the ER diagram to the relational model.

4 Entities & Entity Sets An entity is a “thing” or “object” in the real world that is distinguishable from other objects. An entity set (or entity class) is a set of things or objects that are described by the same properties. E.g., Joe Dahmer is a person. “Persons” is an entity class described by, say, name, address, height, weight, fingerprint, age and gender. Hence, Joe Dahmer, who is an element of the entity set “persons” is described by these properties. In the example above, Joe Dahmer is the entity and “persons” is the entity class or entity set. Consider 2 entity sets, “employees” and “persons”. “Employees” may be described by additional properties, such as salary and grade. Joe Dahmer could be a member of both sets.

5 Attributes An attribute is a descriptive property possessed by each element (or entity) in an entity set. E.g., the entity set “persons” in the previous slide has seven attributes. Each attribute is associated with a domain. E.g., name is associated with the character string domain. fingerprint is associated with the JPEG domain. The domain is the set of permitted values of the attribute. The domain is similar to type in programming languages, and the attribute is similar to a variable of that type.

6 Types of Attributes Simple & Composite Attributes Simple attributes cannot be divided into subparts, while composite attributes can be divided into sub-parts. E.g., name may be divisible into first-name, middle-name and last-name. Address may consist of street and city. Street may be further decomposed into street_info and apartment_info. City may be further decomposed into city_name, state_name and zip_code. Single-Valued and Multivalued Attributes Some attributes, such as height, are single valued, i.e., they have only one value at a time. Other attributes, such as dependent_name, may be multivalued, i.e., they can have multiple values at the same time (in this case, if there is > 1 dependent for a person).

7 Types of Attributes Null Attributes A null attribute is one that can have a null value. Null can mean one of two things, we don’t know which. E.g., a dependent value being null could mean that there are no dependents, OR that there are dependents but we don’t have information on them. Derived Attribute A derived attribute is one whose value can be mathematically derived from existing data. E.g., If an employee has a start_date and an end_date, then the tenure attribute is a derived attribute.

8 Relationships and Relationship Sets A relationship is an association among two or more entities. E.g., Akhilesh (entity) teaches (relationship) MIS3053_fall_2010_sectionA (entity). A relationship set is a set of relationships of the same type. E.g., Professors (entity set) teach (relationship set) course_sections (entity set). Relationship sets relate entity sets in meaningful, real world relationships. Each entity set involved in a relationship set plays a role in that relationship set. E.g., Professors play the role of teachers in the teach relationship set. Course_sections play the role of taught by in the teach relationship set.

9 Attributes of Relationship Sets An attribute of a relationship set is very similar to an attribute of an entity set. Attributes of relationship sets are used when we are trying to capture additional information about the relationship set. E.g., the teach relationship set may have the attributes date_began, date_ended. These 2 relationship set attributes of the teach relationship set tell us the beginning and ending dates that the course_section was taught. Each relationship in the relationship set will have values for the relationship set attributes. So, the relationship Akhilesh teaches MIS3053_fall_2010_sectionA will have the values ‘August 23, 2010’ and ‘Dec 8, 2010’ for the date_began and date_ended attributes.

10 Fun In Class Example The University of Sherwood has students, professors and courses. Students have a student_id, last_name, middle_initial, first_name, date of birth, address, several emails and several phone numbers. Professors have fac_id, name, highest)degree, subject area. Courses have course_id, title, description, number of credits. A course is taught many times, often by different professors. Students take courses and get grades. Sherwood offers many majors, and Professors advise students in their major. A Professor may be qualified to advise in more than one major, and a student may take more than one major. Each student needs an advisor for every major in which they are enrolled. Course are linked to majors, with each course being linked to on or more majors. A course may be required or optional for a major. Draw an ER sketch for these requirements.

11 Degree of Relationship Sets The degree of a relationship set is the number of entity sets that participate in the relationship set. E.g., the degree of the teach relationship set is 2. It is a binary relationship set. Consider a relationship set between students, degree majors and professors, called advise. Advise is a ternary relationship set. While we can theoretically have a relationship set that is n-ary, in reality, most relationship sets are binary, and occasionally, ternary.

12 Cardinalities of Relationship Sets Cardinalities express the number of entities to which another entity may be associated via a relationship set. For a binary relationship set (between, say, entity sets A and B): 1:1: Each entity in entity set B is associated with at least one entity in entity set A, and at most one entity in entity set A. The 1:1 shows up on the A side. 1:n: Each entity in B is associated with at least one entity in entity set A, and at most any number of entities (>0) in entity set A. The 1:n shows up on the A side. 0:n: at least 0 entities, at most n entities. m:n: at least any number (>0) and at most any number (>0). Here we would write an actual number for m, and maybe an actual number for n.

13 Cardinalities of Ternary Relationship Sets Cardinalities of ternary relationship sets are best illustrated by an example. Consider the (ternary) relationship set advise between Professors, students and degree majors. For each combination of Professor and Student (e.g., Akhilesh, Bill) how many minimum majors can there be? How many maximum majors? The minimum and maximum values are the cardinality numbers written on the degree majors side. Similarly, for each Student and degree major combination, how many minimum and maximum Professors are there? These are the cardinality numbers written on the Professors side.

14 Several software are available for drawing ER diagrams. Each one uses a slightly different convention. We shall use a convention that covers more than almost all conventions, and is as follows: Drawing ER diagrams Entity Set Attribute (underlined if a primary key) Link between entity set and attribute 0:1 0:n Relationship Set Cardinality Role MinimumMaximum

15 Example of binary teach relationship set, and ternary advise relationship set. Drawing ER diagrams

16 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?

17 One strategy is to model actions (verbs) as relationships and nouns as entities. E.g., Professors teach Course_sections. 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 1 © Akhilesh Bajaj, 2000, 2002, 2003, 2004."

Similar presentations


Ads by Google