1 / 19

Lecture 5

Lecture 5. 21/10/13. An Associative Entity. A many to many relationship hides another entity In order to alleviate this, an associative entity is created An associative entity is a combination of an entity and relationship

didina
Download Presentation

Lecture 5

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lecture 5 21/10/13

  2. An Associative Entity • A many to many relationship hides another entity • In order to alleviate this, an associative entity is created • An associative entity is a combination of an entity and relationship • The primary key of the associative entity is comprised of the two primary keys of the two entities from which it was derived

  3. Many-to-Many Relationship (N:M) • Many-to-many relationships occur where many instances of an entity relate to many instances of a second entity • These relationships usually contain a hidden entity which should be extracted • Usually N:M relationships are broken into one or more pairs of one-to-many relationships

  4. Associative Entities • The many to many cardinality should be positioned towards the associative entity. • An associative entity may also be referred to as a link entity.

  5. Creating an Associative Entity Doctor Patient Has an appointment with

  6. Creating an Associative Entity Doctor Patient conducts present at Appointment

  7. Another example Engineer Project Works on Worked on Works on Engineer Contract Project

  8. Another example Film Actor Appears in makes contains Film Appearance Actor

  9. Primary and Foreign Keys • We have stated that a primary key or key attribute uniquely identifies an entity instance e.g. Customer ID. • A foreign key is an attribute that appears as a non-key attribute in one table (entity) and as the primary key of another table (entity).

  10. Foreign Key Tutorial Schedule Tutor Is assigned

  11. Data Modeling Concepts: Generalization Generalization – a concept wherein the attributes that are common to several types of an entity are grouped into their own entity. Supertype – an entity whose instances store attributes that are common to one or more entity subtypes. Subtype – an entity whose instances may inherit common attributes from its entity supertype And then add other attributes that are unique to the subtype.

  12. Example: Is cared for by Physcian Patient Is a Is a OutPatient Resident Patient Bed Is assigned

  13. Example • Patient is the supertype which is conneted to two subtypes Outpatient and Resident Patient • Attributes that are shared by all patients are associated with the supertype • Attributes that are unique to a particular subtype are only associated with that subtype • Relationships in which all types of patients participate are associated with the supertype • Relationships in which only a subtype participates is associated only with the relevant subtype.

  14. Example: Admit_Date Physician_id Patient_Id Is cared for by Physcian Patient Patient_Name Is a Is a OutPatient Resident Patient Bed Is assigned Date Discharge Checkback Date Bed_Id

  15. What is a Good Data Model? • A good data model is simple. • Attributes that describe any given entity should describe only that entity. • Each attribute of an entity instance can have only one value.

  16. What is a Good Data Model? • A good data model is essentially nonredundant. • This means: • Each data attribute, other than foreign keys, describes at most one entity. • Look for the same attribute recorded more than once under different names. • A good data model should be flexible and adaptable to future needs.

  17. Data Analysis Data analysis – a technique used to improve a data model for implementation as a database. Goal is a simple, nonredundant, flexible, and adaptable database.

  18. Recap • An entity is….. • A primary key is…. • An attribute is…. • A relationship is…. • Cardinality is….

  19. Entity Relationship Diagram (ERD) Exercise - vehicle rental company • AllCars wishes to create a system to monitor the rental of vehicles to clients. The company has various outlets and each outlet has staff including a Manager and a number of mechanics. Each outlet has a stock of vehicles for rent that may be rented by clients for various periods of time. Each rental agreement between the customer and AllCars is identified through a rental number. A client must take out insurance cover for each vehicle rental period and a vehicle is checked for faults after each rental. • Draw an ERD that represents the system outlined above. • Include the cardinality and for the relationships identified in the model.

More Related