dbmsunit2 (1)
dbmsunit2 (1)
5.Describe mapping constraints with its types. OR Describe mapping constraints with its types.
1. Mapping constraints act as a rule followed by contents of database.
2. Data in the database must follow the constraints.
Types of mapping constraints are :
1. Mapping cardinalities :
a. Mapping cardinalities (or cardinality ratios) specifies the number of entities of which another entity can be
associated via a relationship set.
b. Mapping cardinalities are used in describing binary relationship sets, although they contribute to the description of
relationship sets that involve more than two entity sets.
c. For binary relationship set R between entity sets A and B, the mapping cardinality must be one of the following :
i. 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.
ii. One to many : An entity in A is associated with any number of entities in B. An entity in B, however, can be
associated with at most one entity in A.
iii. Many to one : An entity in A is associated with at most one entity in B, and an entity in B, however, can be
associated with any number of entities in A.
iv. Many to many : An entity in A is associated with any number of entities in B, and an entity in B is associated with
any number of entities in A.
2. Participation constraints :
It tells the participation of entity sets. The participation constraints specify whether the existance of an entity depends
on its being related to another entity via the relationship type.
There are two types of participations :
i. Partial participation
ii. Total participation
1. Primary key :
a. Primary key uniquely identifies each record in a table and must never, be the same for records. Here in Employee
table we can choose either EmployeeID or SSN columns as a primary key.
b. Primary key is a candidate key that is used for unique identification of entities within the table.
c. Primary key cannot be null.
d. Any table has a unique primary key.
2. Super key :
a. A super key for an entity is a set of one or more attribute whose combined value uniquely identifies the entity in the
entity set.
b. For example : Here in employee table (EmployeeID, FullName) or
(EmployeeID, FullName, DeptID) is a super key.
3. Candidate key :
a. A candidate key is a column, or set of column, in the table that can uniquely identify any database record without
referring to any other data.
b. Candidate key are individual columns in a table that qualifies for uniqueness of all the rows. Here in Employee
table EmployeeID and SSN are candidate keys.
c. Minimal super keys are called candidate keys.
4. Composite key :
a. A composite key is a combination of two or more columns in a table that can be used to uniquely identify each row
in the table.
b. It is used when we cannot identify a record using single attributes.
c. A primary key that is made by the combination of more than one attribute is known as a composite key.
5. Alternate key :
a. The alternate key of any table are those candidate keys which are not currently selected as the primary key.
b. Exactly one of those candidate keys is chosen as the primary key and the remainders, if any are then called alternate
keys.
c. An alternate key is a function of all candidate keys minus the primary key. d. Here in Employee table if
EmployeeID is primary key then SSN would be the alternate key.
6. Foreign key :
a. Foreign key represents the relationship between tables and ensures the referential integrity rule.
b. A foreign key is derived from the primary key of the same or some other table.
c. Foreign key is the combination of one or more columns in a table (parent table) at references a primary key in
another table (child table).
d. A foreign key value can be left null. For example : Consider another table : Project (ProjectName, TimeDuration,
EmployeeID)
a. Here, the ‘EmployeeID’ in the ‘Project’ table points to the ‘EmployeeID’ in ‘Employee’ table
b. The ‘EmployeeID’ in the ‘Employee’ table is the primary key.
c. The ‘EmployeeID’ in the ‘Project’ table is a foreign key.
7. What do you mean by a key to the relation ? Explain the differences between super key, candidate key and
primary key.
8. Discuss extended or enhanced ER model (EERM).
1. The ER model that is supported with the additional semantic concepts is called the extended entity relationship
model or EER model.
2. The EER model includes all the concepts of the original ER model together with the following additional concepts
a. Specialization : explain in detail
b. Generalization : explain in detail
c. Aggregation : explain in detail
3. The super class/subclass entity types (or super type /subtype entities) is one of the most important modelling
constructs that is included in the EER model.
4. This feature enables us to model a general entity and then subdivide it into several specialized entity types
(subclasses or subtypes).
5. EER diagrams are used to capture business rules such as constraints in the super type/subtype relations. Thus, a
super class is an entity type that includes distinct subclasses that require to be represented in a data model.
6. A subclass is an entity type that has a distinct role and is also a member of a super class.
9 .Explain the reduction of ER schema to tables. OR How to reduce an ER model into table ?
1. In ER model, database are represented using the different notations or diagrams, and these notations can be reduced
to a collection of tables.
2. In the database, every entity set or relationship set can be represented in tabular form.
Consider following ER diagram :
Basic rules for converting the ER diagrams into tables are :
1. Convert all the entities in the diagram to tables :
a. All the entities represented in the rectangular box in the ER diagram become independent tables in the database. b.
In the ER diagram, Student, Course, Lecturer and Subjects forms individual tables.
2. All single-valued attribute becomes a column for the table :
a. All the attributes, whose value at any instance of time is unique, are considered as columns of that table.
b. In the Student entity, Student_Name and Student_ID form the column of Student table. Similarly, Course_Name
and Course_ID form the column of Course table and so on.
3. A key attribute of the entity is the primary key :
a. All the attributes represented in the oval shape and underlined in the ER diagram are considered as key attribute
which act as a primary key of table.
b. In the given ER diagram, Student_ID , Course_ID, Subject_ID, and Lecture_ID are the key attribute of the Student,
Course, Subjects and Lecturer entity.
4. The multivalued attribute is represented by a separate table :
a. In the student table, a hobby is a multivalued attribute.
b. So it is not possible to represent multiple values in a single column of Student table. Hence we create a table
Stud_Hobby with column name Student_ID and Hobby. Using both the column, we create a composite key.
5. Composite attributes are merged into same table as different columns :
a. In the given ER diagram, student address is a composite attribute. It contains City, Pin, Door_No, Street, and State.
b. In the Student table, these attributes can merge as an individual column.
6. Derived attributes are not considered in the table :
a. In the Student table, Age is the derived attribute.
b. It can be calculated at any point of time by calculating the difference between current date and Date of Birth (DoB).