Presentation is loading. Please wait.

Presentation is loading. Please wait.

CPSC 603 Database Systems Lecturer: Laurie Webster II, M.S.S.E., M.S.E.E., M.S.BME, Ph.D., P.E. Lecture 2 Introduction to a First Course in Database Systems.

Similar presentations


Presentation on theme: "CPSC 603 Database Systems Lecturer: Laurie Webster II, M.S.S.E., M.S.E.E., M.S.BME, Ph.D., P.E. Lecture 2 Introduction to a First Course in Database Systems."— Presentation transcript:

1 CPSC 603 Database Systems Lecturer: Laurie Webster II, M.S.S.E., M.S.E.E., M.S.BME, Ph.D., P.E. Lecture 2 Introduction to a First Course in Database Systems

2 CPSC 603 Database Systems Relational Models Relational models uses a collection of tables to represent both data and relationships among those data

3 Controlling Redundancy Redundancy  storing the same data multiple times => leads to several problems!!! 1.Need to perform a single logical update - such as entering data on a new student - multiple times - once for each file where student data is recorded => duplication of effort 2.Storage space is wasted when same data is stored repeatedly 3.Files that represent the same data may become inconsistent

4 Controlling Redundancy Inconsistent => may happen because an update is applied to some of the files but not to others

5 Three Aspects of Studying DBMS’s Modeling and Design of Databases –Allows exploration of issues before committing to an implementation Programming:Queries and DB operations like update – SQL = “intergalactic dataspeak” DBMS implementation

6 Entity/Relational Model Diagrams to represent designs Entity like object,= “thing.” Entity set like class - set of “similar” entities / objects. Attribute = property of entities in an entity set, similar to fields of a struct.

7 Entity/Relationship Model Diagrams In Diagrams: Entity set  rectangle Attribute  oval ID Name Phone Height Students

8 Relationships Connect two or more entity sets (E.S.) diamondsRepresented by diamonds. Taking StudentsCourses Relationship between Students and Courses Students take Courses Relationship is taking

9 Relationship Sets Think of the “value” of a relationship set as a table. –One column for each of the connected entity sets –One row for each list of entities, one from each set, that are connected by the relationship

10 Relationship Set Students Courses SallyCPSC 310 SallyCPSC 603 JoeCPSC 420 …………………. One column for each of the connected entity sets 1) Students 2) Courses One row for each list of entities 1. (Sally,…) and 2. (CPSC 310, ….)

11 Multiway Relationships Binary Relationships Suffice However, there are some cases where three or more E.S. must be connected by one relationship Example: Relationship among students, courses, TA’s. Possibly, this E/R diagram shown next will be O.K.

12 Multiway Relationship Students, Courses, TA’s Students TakingCourses Assisting TAs

13 Multiway Relationships This works with CPSC 310(603), because each TA is a TA of all students. Connection student-TA is only via the course But what if students were divided into sections, each headed by a TA? –Then, a student in CPSC 310 would be related to only one of the TA’s for CPSC 310. Which one? Need a 3-way relationship to tell

14 Elements of the E/R Model continued (Chapter 2 of Text) Entity Types, Entity Sets,Keys, and Value Sets Entity Types and Entity Sets A database usually contains groups of entities that are similar For Example: A company employing hundreds of employees may want to store similar information concerning each of the employees.

15 Entity Type An Entity Type defines a collection (set) of entities that have the same attributes Each Entity Type in the database is described by its name and attributes

16 Key Attributes of an Entity Type An important Constraint on the entities of an entity type is the key or uniqueness constraint on attributes An entity type usually has an attribute whose vaues are distinct for each individual entity in the collection => such an attribute is called a key attribute

17 Key Attributes of an Entity Type For the Person Entity ==> A typical Key Attribute is SSN#

18 Key Attributes of an Entity Type In the ER Diagrammatic notation, each Key Attribute has its name underlined inside the Oval EMPLOYEE SSN Attribute Entity

19 Weak Entity Sets Sometimes an E.S. E’s key comes not (completely) from its own attributes, but from the keys of one or more E.S.’s to which E is linked by a supporting many-to-one relationship Called a weak E.S. Represented by putting a double rectangle around E and a double diamond around each supporting relationship

20 Weak Entity Sets Sometimes an E.S. E’s key comes not (completely) from its own attributes, but from the keys of one or more E.S.’s to which E is linked by a supporting many-to-one relationship Many-one-ness of supporting relationship (includes 1-1) essential –With many-many, we wouldn’t know which entity provided the key value. “Exactly one” also essential, or else we might not be able to extract key attributes by following the supporting relationship

21 Entity-Relationship Diagram A Movie Database Movies Title Year Length filmType Stars-InStars NameAddress Owns Studios Name Address

22 Multiway Relationships Example 2.5 Contracts In Fig. 2.4 is a relationship Contracts that involves a studio, a star, and a movie. This relationship represents that a studio has contracted with a particular star to act in a particular movie. Stars CONTRACTS Movie Studio A Three-Way relationship

23 Roles in Relationships-Fig. 2.5 It is possible that one entity set appears two or more times in a single relationship –If so, we draw as many lines from the relationship to the entity set as the entity appears in the relationship. Each line to the entity set represents a different role that the entity set plays in the relationship Sequel-of Movie Sequel Original

24 Roles in Relationships-Fig. 2.5 In Sequel-of the relationship is between the entity set Movies and itself Sequel-of Movies Original Sequel

25 Next Lecture Database Design Principles Modeling of Constraints Weak Entity Sets Summary of Chapter 2 Relational Data Model


Download ppt "CPSC 603 Database Systems Lecturer: Laurie Webster II, M.S.S.E., M.S.E.E., M.S.BME, Ph.D., P.E. Lecture 2 Introduction to a First Course in Database Systems."

Similar presentations


Ads by Google