preview

Entity-Relationship Diagrams and the Relational Model

Decent Essays

Review Entity-Relationship Diagrams and the Relational Model
CS 186, Fall 2007, Lecture 2 R & G, Chaps. 2&3
A relationship, I think, is like a shark, you know? It has to constantly move forward or it dies. And I think what we got on our hands is a dead shark.
Woody Allen (from Annie Hall, 1979)

• Why use a DBMS? OS provides RAM and disk

Review
• Why use a DBMS? OS provides RAM and disk
– Concurrency – Recovery – Abstraction, Data Independence – Query Languages – Efficiency (for most tasks) – Security – Data Integrity

Data Models

• DBMS models real world • Data Model is link between user’s view of the world and bits stored in computer • Many models exist • We think in terms of..
Relational Model (clean and common) – …show more content…

– Owner entity set and weak entity set must participate in a one-to-many relationship set (one owner, many weak entities). – Weak entity set must have total participation in this identifying relationship set. name ssn lot cost pname age

• Basically means “at least one” name ssn Employees lot Manages since did dname budget Departments

Works_In

Means: “exactly one” since Employees

Policy

Dependents

Weak entities have only a “partial key” (dashed underline)

Binary vs. Ternary Relationships ssn name lot Covers pname age

Binary vs. Ternary Relationships (Contd.)
• Previous example illustrated a case when two binary relationships were better than one ternary relationship.

If each policy is owned by just 1 employee:

Employees

Dependents

Bad design
Key constraint on Policies would mean policy can name ssn only cover 1 dependent! • Think through all the constraints in the 2nd diagram! policyid lot

Policies cost pname age

Employees Purchaser

Dependents

Beneficiary

• An example in the other direction: a ternary relation Contracts relates entity sets Parts, Departments and Suppliers, and has descriptive attribute qty. No combination of binary relationships is an adequate substitute. (With no new entity sets!)

Better design policyid Policies cost

Binary vs. Ternary Relationships (Contd.) qty Parts Contract Departments

Summary so far
• Entities and Entity Set (boxes) • Relationships and Relationship sets

Get Access