Presentation is loading. Please wait.

Presentation is loading. Please wait.

A short review on entity- relationship modelling.

Similar presentations


Presentation on theme: "A short review on entity- relationship modelling."— Presentation transcript:

1 A short review on entity- relationship modelling

2 Entity/Relationship Models An Entity/Relationship model consists of diagrams to represent designs. Entity like object = ”thing.” Entity sets like class = set of ”similar” entities/objects. Attribute = property of entities in an entity set. Relationships connect different entity type.

3 Entity/Relationship Models In diagrams: entity sets are rectangles; attributes are oval; relationship sets are diamonds.

4 Multiway Relationships Usually relationships are binary. That is they connect two entity types. However, there are some cases where three or more entity types must be connected by one relationship. These relationships are called multiway relationships.

5 Roles A recursive relationship is a relation type where the same entity participates more than one in different roles. We label each edge with the role name.

6 An Example

7 Multiplicity of relationships Many to Many relation: Bars serve different beers Many to One relation: Drinkers have favorite beers One to One relation: Breweries have only one best seller

8 Total participation If all the elements of the entity type E are related to some element of an entity type F via a relationship R, then the participation of E in R is called total participation. Example: breweries must have one best seller beer.

9 Keys A key is a set of attributes such that no two entities agree on all these attributes. In E/R model every entity type must have a designated key. In E/R diagrams you should underline all attributes of the key.

10 Weak entities Entity sets that do not have key attributes of their own are called weak entity types. The remaining attributes come from another (or more) entity type which is related to the weak entity set by an identifying (1 to M) relationship. The weak entity set must have total participation in the identifying relationship. IN E/R diagrams you should represent weak entity sets as double rectangles represent identifying relationships as double diamonds Partial key

11 ISA (`is a’) Hierarchies Contract_Emps name ssn Employees lot hourly_wages ISA Hourly_Emps contractid hours_worked  As in C++, or other PLs, attributes are inherited.  If we declare A ISA B, every A entity is also considered to be a B entity. Overlap constraints: Can Joe be an Hourly_Emps as well as a Contract_Emps entity? (Allowed/disallowed) Covering constraints: Does every Employees entity also have to be an Hourly_Emps or a Contract_Emps entity? (Yes/no) Reasons for using ISA : – To add descriptive attributes specific to a subclass. – To identify entitities that participate in a relationship.

12 Aggregation Used when we have to model a relationship involving (entitity sets and) a relationship set. – Aggregation allows us to treat a relationship set as an entity set for purposes of participation in (other) relationships. * Aggregation vs. ternary relationship :  Monitors is a distinct relationship, with a descriptive attribute.  Also, can say that each sponsorship is monitored by at most one employee. budget did pid started_on pbudget dname until Departments Projects Sponsors Employees Monitors lot name ssn since

13 Exercise Suppose you are hired to develop a geographical information system. Your task is to develop its databases, with the following information: A continent has a name and contains different countries (e.g., Europe). Each country resides only in one continent. Each country has a name, a population value, official language(s), and its capital city. Each official language may be shared by different countries (e.g.English). Each language has a unique ID (LangID) and a name. Each city carries a name and a population value. Each city resides only in one country. The name of each city is unique within its country. Each river has a unique ID (RiverID), a name, and its length. Rivers run through one or more countries. International treaties are identified by their names. They also contain their subjects as well as starting dates. Each treaty consists of at least two countries. 1.Design and draw an E/R diagram that captures the above information. Be careful to indicate any key and participation constraints (multiplicity constraints). 2.Convert the E/R diagram to a relational database schema.

14 Exercise A continent has a name and contains different countries (e.g., Europe). Each country resides only in one continent. Each country has a name, a population value, official language(s), and its capital city. Each official language may be shared by different countries (e.g.English). Each language has a unique ID (LangID) and a name. Each city carries a name and a population value. Each city resides only in one country. The name of each city is unique within its country. Each river has a unique ID (RiverID), a name, and its length. Rivers run through one or more countries. International treaties are identified by their names. They also contain their subjects as well as starting dates. Each treaty consists of at least two countries.

15 Solution

16 Solution (Cont.)


Download ppt "A short review on entity- relationship modelling."

Similar presentations


Ads by Google