2.entity Relationship Model
2.entity Relationship Model
1. Explain specialization and generalization feature of ER diagram with example [LJIET]Dec 2009 3
OR
Explain generalization and specialization in ER diagram with suitable example [LJIET]May 2011 May
2013
OR
Explain gernarization feature of E-R Diagram.[LJIET]Dec 2011
(1)Generalization
Generalization is a process of defining a more general entity type from a set of more specialized entity
types.
Generalization is bottom up approach
Consider that the attributes of customer entity are customer id, name, street, city and Employee entity
attributes are Employee code, street city and salary. Thus entity sets Employee and Customer have
several attributes in common. This commonality can be expressed by generalization.
One type of constraints involve determining which entities can be members of given lower level entity
set. Such membership may be Condition defined or user defined.
Second type of constraints relates to whether or not entities may belong to more than one lower level
entity set within a single generalization. The lower level entity sets may be disjoint or overlapping.
The diagram below shows generalization. Generalization of Employee and Customer is Person Entity.
Employee and Customer will have common attribute of Person entity that are Name, Street and City.
(2) Specialization
The process of designating subgroupings within an entity set is called specialization
Specialization is top-down process
Above figure shows specialization which is representation by triangle. The label ISA stands for ―is a‖
and represents for example customer ―is a‖ person.
An entity set may include subgroupings of entities that are distinct in some way from other entities in the
set. For instance, a subset of entities within an entity set may have attributes that are not shared by all the
entities in the entity set. Consider an entity set Person with attributes Name, Street and city.
The entity set person may be further classified as one of the following:
Employee
Customer
Each of these person types is described by a set of attributes that includes all the attributes of entity set
person plus possibly additional attributes. For example, employee entities may be described further by
the attribute salary, whereas Customer entities may be described further by an attribute credit-rating.
The specialization of person allows us to distinguish among person entities according to whether they
correspond to employees or customers: in general, a person could be an employee, a customer, both, or
neither.
We can apply specialization repeatedly to refine a design scheme.
Bank employees may be further classified as
Officer
Teller
Prepared By: - Prof. Munira Topia Computer Engineering Department, L. J. Institute of Engineering & Technology, Ahmedabad
2
Secretary
Each of these employee types is described by a set of attributes that includes all the attributes of entity set
employee plus additional attributes.
2. Construct E-R diagram for a hospital with a set of patients and medical doctors. associate with each 4
patient a log of various tests and examinations conducted [LJIET]Dec 2009
OR
Construct E-R diagram for a hospital with a set of patients and medical doctors. Associate with each
patient a log of various tests suggested by doctors and Examinations conducted. Use Specialization and
Generalization in your diagram.[LJIET] Nov 2013
OR
Draw an Entity Relation diagram for the Hospital Management System. Consider the different types of
Patients with respect to Disease and In-Patient and Out-Patient Department in the design. Consider the
availability of all well qualified Doctors. Consider various types of tests and operations to be conducted.
Explain the mapping cardinality used. Assume suitable attributes. Use generalization and Specialization.
[LJIET]Dec 2014
OR
Draw E-R diagram for Hospital management system and covert into set of table schema [LJIET]Mar
2010
Prepared By: - Prof. Munira Topia Computer Engineering Department, L. J. Institute of Engineering & Technology, Ahmedabad
3
Aggregation
One limitation of the E-R model is that it cannot express relationships among relationships.
Consider a quaternary relationship Manages between Employee, Branch, Job and Manager. Using basic
E-R modeling constructs, E-R diagram will be as below.
There is redundant information in the resultant figure, since every Employee, Branch, Job combination in
Manages is also Works_on. The best way to model above situations to use aggregation. Aggregation is
an abstraction through which relations are treated as higher level entities. Thus the relationship set
Works_On relating the entity sets Employee, Branch and Job is considered as a higher level entity set
Works_On. We can then create a binary relationship manages between Works_On and Manager to
represent who manages what task. Figure below shows E-R with aggregation.
Prepared By: - Prof. Munira Topia Computer Engineering Department, L. J. Institute of Engineering & Technology, Ahmedabad
4
4. Construct E-R diagram of the bank. It provides different kinds of bank accounts. And loans. It operates 4
number of branches.[LJIET]Dec 2009
OR
Construct E-R diagram for a bank which has many branches and it supports different types of accounts.
It also provides loans to customers. Use Specialization and Generalization in your diagram.[LJIET] Nov
2013
5. With example explain various mapping cardinalities and total participation [LJIET]Mar 2010 7
OR
Explain Mapping Cardinalities.[LJIET] May 2012
Prepared By: - Prof. Munira Topia Computer Engineering Department, L. J. Institute of Engineering & Technology, Ahmedabad
5
An E-R enterprise schema defines certain constraints mapping cardinalities and participation constraints.
Mapping Cardinalities
Mapping cardinalities, or cardinality ratios, express the number of entities to which another entity can be
associated via a relationship set.
Mapping cardinalities are most useful in describing binary relationship sets
For a binary relationship set R between entity sets A and B, the mapping cardinality must be one of the
following:
• One-to-one- An entity in A is associated with at most one entity in B, and an entity in B is associated
with at most one entity in A. One-to-one mapping cardinality is shown in figure a.
• One-to-many-An entity in A is associated with any number (zero or more) of entities in B. An entity in
B, however, can be associated with at most one entity in A. One-to- many mapping cardinality is shown
in figure b.
• Many-to—one- An entity in A is associated with at most one entity in B. An entity in B, however, can
be associated with any number (zero or more) of entities in A. Many-to—one mapping cardinality is
shown in figure c.
• Many-to-many- An entity in A is associated with any number (zero or more) of entities in B, and an
entity in B is associated with any number (zero or more) of entities in A. Many-to-many mapping
cardinality is shown in figure d.
(c.) (d)
Consider the advisor relationship set. If, in a particular university, a student can be advised by only one
instructor, and an instructor can advise several students, then the relationship set from instructor to
student is One-to-many. If a student can be advised by several instructors (as in the case of students
advised jointly), the relationship set is many-to-many
Participation Constraints
The participation of an entity set E in a relationship set R is said to be total if every entity in E
participates in at least one relationship in R. If only some entities in E participate in relationships in R, the
participation of entity set E in relationship R is said to be partial.
Prepared By: - Prof. Munira Topia Computer Engineering Department, L. J. Institute of Engineering & Technology, Ahmedabad
6
In Figure a, the participation of B in the relationship set is total while the participation of A in the
relationship set is partial. In Figure b, the participation of both A and B in the relationship set are total.
For example, we expect every student entity to be related to at least one instructor through the advisor
relationship. Therefore the participation of student in the relationship set advisor is total. In contrast, an
instructor need not advise any students. Hence, it is possible that only some of the instructor entities are
related to the student entity set through the advisor relationship, and the participation of instructor in the
advisor relationship set is therefore partial.
Prepared By: - Prof. Munira Topia Computer Engineering Department, L. J. Institute of Engineering & Technology, Ahmedabad
7
OR
Draw ER diagram for Library Management System.[LJIET]May 2013
Prepared By: - Prof. Munira Topia Computer Engineering Department, L. J. Institute of Engineering & Technology, Ahmedabad
8
8. Draw E-R diagram for supplier who supplies different parts. The parts are used in different projects. 5
Explain the mapping cardinality used. Assume suitable attributes.[LJIET]May 2011
9. Give Symbol used in E-R Diagram and Draw the E-R diagram of University exam System[LJIET]Dec 7
Prepared By: - Prof. Munira Topia Computer Engineering Department, L. J. Institute of Engineering & Technology, Ahmedabad
9
2011
Symbols in E-R diagram
Prepared By: - Prof. Munira Topia Computer Engineering Department, L. J. Institute of Engineering & Technology, Ahmedabad
10
Entities are
1) Accident (Report-number, location, date)
2) Person(Driver-id, address, name)
3) Car(License, model, year)
Relationships
1)Owns relationship between entity person and Car
2) participated relationship between person and accident with attribute damage-amount
11. Obtain E-R diagram for the Admission procedure in a university. An advertisement is issued giving 5
essential qualifications for the course, the last date for recipient of application, and the fee to be
enclosed with the application. A clerk in the registrar's office checks the received applications to see if
mark sheet and the fee are enclosed and sends valid application to the concerned academic
department. The department checks the application in detail and decides the applicant to be admitted,
those to be put in the waiting list, and those to be rejected. Appropriate letters are sent to the registrar's
office which intimates the applicant. [LJIET] May 2012
Prepared By: - Prof. Munira Topia Computer Engineering Department, L. J. Institute of Engineering & Technology, Ahmedabad
11
12. What is Entity-Relationship model? Explain the steps to reduce the ER diagram to ER database 7
schema. [LJIET] Jan 2013
Both the E-R model and the relational database model are abstract, logical representations of real-world
enterprises. Because the two models employ similar design principles, we can convert an E-R design
into a relational design.
Constraints specifying from the E-R design can be mapped to Constraints on relation schemas
Primary keys allow entity sets and relationship sets to be expressed uniformly as relation schemas
that represent the contents of the database.
A database which conforms to an E-R diagram can be represented by a collection of schemas.
For each entity set and relationship set there is a unique schema that is assigned the name of the
corresponding entity set or relationship set.
Each schema has a number of columns (generally corresponding to attributes), which have unique
names
A strong entity set reduces to a schema with the same attributes. customer(costumer id, costumer
name, costumer street, costumer city)
A weak entity set becomes a table that includes a column for the primary key of the identifying
strong entity set
A many-to-many relationship set is represented as a schema with attributes for the primary keys of
the two participating entity sets, and any descriptive attributes of the relationship set.
Composite attributes are flattened out by creating a separate attribute for each component attribute
Prepared By: - Prof. Munira Topia Computer Engineering Department, L. J. Institute of Engineering & Technology, Ahmedabad
12
(1) Primary Key - A primary key is a field in a table which uniquely identifies each row/record in a
database table. Primary keys must contain unique values. A primary key column cannot have
NULL values. A table can have only one primary key, which may consist of single or multiple
fields
(2) Foreign Key - A foreign key is a column (or columns) that references a column (most often the
primary key) of another table. The purpose of the foreign key is to ensure referential integrity of
the data. In other words, only values that are supposed to appear in the database are permitted
(3) Unique Key - In database relational modeling and implementation, a unique key is a set of zero,
one, or more attributes. The value(s) of these attributes are required to be unique for each tuple
(row) in a relation.
(4) Not null - The NOT NULL constraint enforces a column to NOT accept NULL values.
The NOT NULL constraint enforces a field to always contain a value. This means that you
cannot insert a new record, or update a record without adding a value to this field.
(5) Commit - Use the COMMIT statement to end your current transaction and make permanent all
changes performed in the transaction. Changes permanent means it will save all the changes in
secondary memory that is stable storage.
(6) Candidate Key - A candidate key is a minimal superkey, that is, a set of attributes that forms a
superkey
(7) Rollback - causes the current transaction to be rolled back; that is, it undoes all the updates
performed by the SQL statements in the transaction. Thus, the database state is restored to what
it was before the first statement of the transaction was executed
Prepared By: - Prof. Munira Topia Computer Engineering Department, L. J. Institute of Engineering & Technology, Ahmedabad
13
14. Define: (1) Weak entity (2) Data Dictionary (3) Substring() (4) Dual (5)Alter (6) Truncate (7) 7
Drop. [LJIET] Jan 2013
(1)Weak entity - An entity set that does not have a primary key is referred to as a weak entity set
(2) Data Dictionary - A relational database system needs to maintain data about the relations, such as
the schema of the relations. Such ―data about data‖ is referred to as metadata. Relational schemas and
other metadata about relations are stored in a structure called the data dictionary
(3) Substring – Returns a portion of a character beginning at character m, and going upto character n
Example – SQL>select substr(‗SECURE‘,3,4) from dual; will return ‗cure‘
(4) Dual - The DUAL is special one row, one column table present by default in all Oracle databases.
The owner of DUAL is SYS but DUAL can be accessed by every user. The table has a single
VARCHAR2(1) column called DUMMY that has a value of 'X'. SQL allows DUAL to be specified as a
table in queries that do not need data from any tables. Example SQL> select 25*25 from dual;
(5) Alter - The structure f a table can be modified using alter table command. Alter table allows
changing the structure of an existing table. With alter table it is possible to add or delete columns,
change the data type of existing columns.
(7) Drop – Drop table command with table name can destroy a specific table.
Example - SQL> drop table students
Will delete student table.
15. Explain following terms with suitable example.[LJIET] Nov 2013 7
(1) Primary Key (2) Candidate Key (3) Foreign Key (4) On Delete Cascade
(1) Primary Key - A primary key is a field in a table which uniquely identifies each row/record in a
database table. Primary keys must contain unique values. A primary key column cannot have NULL
values. A table can have only one primary key, which may consist of single or multiple fields
(2) Candidate Key - A candidate key is a minimal superkey, that is, a set of attributes that forms a
superkey
(3) Foreign Key - A foreign key is a column (or columns) that references a column (most often the
primary key) of another table. The purpose of the foreign key is to ensure referential integrity of the
data. In other words, only values that are supposed to appear in the database are permitted
(4) On Delete Cascade - On delete cascade referential action for a foreign key that allows you to delete
data from child tables automatically when you delete the data from the parent table. When on delete
cascade option is specified in the foreign key definition if a record is deleted in the master table, all
corresponding records in the details table along with the records in master table will be deleted.
Prepared By: - Prof. Munira Topia Computer Engineering Department, L. J. Institute of Engineering & Technology, Ahmedabad
14
The overall logical structure of a database can be expressed graphically using E-R diagram. Such a diagram
consists of the following major components.
o Rectangles -divided into two parts represent entity sets. The first part, which in this textbook is
shaded blue, contains the name of the entity set. The second part contains the names of all the
attributes of the entity set.
o Diamonds represent relationship sets.
o Attributes that are part of the primary key are underlined.
o Lines link entity sets to relationship sets.
o Dashed lines link attributes of a relationship set to the relationship set.
o Double lines indicate total participation of an entity in a relationship set.
o Double diamonds represent identifying relationship sets linked to weak entity sets
o Dashed Ellipse – Dashed ellipse is used to show derived attribute. The attribute which value is
derived from another attribute is called derived attribute.
o Double rectangle – Weak entity is represented by double rectangle. An entity set that does not have a
primary key is referred to as a weak entity set.
Above E-R diagram shows multi valued attribute phone_number, composite attribute address and
street, derived attribute age as dotted ellipse.
Prepared By: - Prof. Munira Topia Computer Engineering Department, L. J. Institute of Engineering & Technology, Ahmedabad