cit 381 more er modeling - review one-to-many - one-to-one - recursive relationships

12
CIT 381 More ER Modeling - review one-to-many - one-to-one - recursive relationships

Post on 20-Jan-2016

220 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CIT 381 More ER Modeling - review one-to-many - one-to-one - recursive relationships

CIT 381

More ER Modeling

-review one-to-many-one-to-one-recursive relationships

Page 2: CIT 381 More ER Modeling - review one-to-many - one-to-one - recursive relationships

Review:

One-to-many and many-to-one

One movie is stored on many videos – many videos are in one store.Both relationships are mandatory. (Why?)

Page 3: CIT 381 More ER Modeling - review one-to-many - one-to-one - recursive relationships

Review: one-to-many optional Here a mechanic can service many cars but a car does not need to have a mechanic.

Page 4: CIT 381 More ER Modeling - review one-to-many - one-to-one - recursive relationships

Review: resolve many-to-many

Here an employee can work in many stores, and a store can have many employees.Use bridging entity for M:N relationships

starting with this

change to this

Page 5: CIT 381 More ER Modeling - review one-to-many - one-to-one - recursive relationships

Review: weak entity

•A weak entity is –An entity with no key of its own–An entity whose instances cannot exist without being related to other entities

•An identifying relationship type is–A relationship type that determines the keys of the weak entities

•Weak entities in IDEF1X have rounded corners.•Identifying relationships are solid lines, non-identifying are dotted lines

Page 6: CIT 381 More ER Modeling - review one-to-many - one-to-one - recursive relationships

Other relationships

Note: only the first three possible in ER Studio.Usually they’d use a dotted line.

Page 7: CIT 381 More ER Modeling - review one-to-many - one-to-one - recursive relationships

Participation• A car has zero or one mechanics (mech_ssn can be null).• Every mechanic must be the mechanic of some car.

• The “P” stands for participates.• It does not affect the table design, it’s just information for us.

Page 8: CIT 381 More ER Modeling - review one-to-many - one-to-one - recursive relationships

One-to-one relationships Suppose we have store and employee entities.

Each store has one manager. An employee can only manage one store.

Page 9: CIT 381 More ER Modeling - review one-to-many - one-to-one - recursive relationships

More one-to-one What does the Z mean when we have a 1:1 relationship?

It is not related to “optional”.

An employee will manage either one store or zero stores.

“Optional” means that a store could exist with no manager.

Page 10: CIT 381 More ER Modeling - review one-to-many - one-to-one - recursive relationships

Role names Instead of ssn, we might want to rename the foreign key to manager_ssn.

In ER Studio we would use the “edit rolenames” feature

Page 11: CIT 381 More ER Modeling - review one-to-many - one-to-one - recursive relationships

Recursive relationship It is possible to have a relationship between an entity and itself.

Rolenames are required. ex: one employee can be the supervisor of another.

Page 12: CIT 381 More ER Modeling - review one-to-many - one-to-one - recursive relationships

Time to talk about keys Superkey Candidate Key Primary Key Alternate Key Surrogate Key