ER example : movie & category M_id Title Cat_id 10001 Forest Gump C102 10002 Iron man C103 10003 Ender Game C101 Cat_id Type C101 Sci Fi C102 Drama C103 Action
If we have a new category, we can insert into category. M_id Title Cat_id 10001 Forest Gump C102 10002 Iron man C103 10003 Ender Game C101 Cat_id Type C101 Sci Fi C102 Drama C103 Action C104 Cartoon
If we have a new category, we can insert into category. If we change category type, we can do in category. 1 2 M_id Title Cat_id 10001 Forest Gump C102 10002 Iron man C103 10003 Ender Game C101 Cat_id Type C101 Sci Fi C102 Drama C103 Action & Advenger C104 Cartoon 2 1
Maintaining History of Time-Variant Data Normally, existing attribute values are replaced with new value without regard to previous value Time-variant data: Values change over time Must keep a history of data changes Keeping history of time-variant data equivalent to having a multivalued attribute in your entity Must create new entity in 1:M relationships with original entity New entity contains new value, date of change
Fan Traps Design trap occurs when relationship is improperly or incompletely identified Represented in a way not consistent with the real world Most common design trap is known as fan trap Fan trap occurs when one entity is in two 1:M relationships to other entities Produces an association among other entities not expressed in the model
Supertype/subtype relationships
Disjoint and Overlapping Constraints Disjoint subtypes Also called nonoverlapping subtypes Subtypes that contain unique subset of supertype entity set Overlapping subtypes Subtypes that contain nonunique subsets of supertype entity set
Overlapping subtypes
Completeness Constraint Partial completeness Symbolized by a circle over a single line Some supertype occurrences are not members of any subtype Total completeness Symbolized by a circle over a double line Every supertype occurrence must be member of at least one subtype
Transforming the ER diagram into relation Schema diagram The steps: Map regular entities Map weak entities Map binary relationships Map unary relationships Map ternary relationships Mapping Supertype/subtype relationships
Mapping a composite attribute
Looks like this using relational schema Relational schema diagram : Relational schema : CUSTOMER( Custome_ID, Customer_Name, Street, City, State, Zip )
The 1:M Relationship Between PAINTER and PAINTING
Mapping a 1:M relationship
Looks like this using relational schema diagram
Mapping a binary 1:1 relationship Some nurse is not in charge for care center (0,1) All care centers must have a nurse to be in charge (1,1) So,put FK on (0,1) care center
Looks like this using relational schema diagram
Mapping an M:M relationship
Mapping an M:M relationship
Looks like this using relational schema diagram
Mapping weak entities
Looks like this using relational schema diagram
Mapping Supertype/subtype relationships
Looks like this using relational schema diagram
Try this