Dbms Notes Unit 2
Dbms Notes Unit 2
UNIT- 2
Relational Model
1. Features of EER Model
1
Database Management System Unit-2: Relational Model
Similarly, in a school database, persons can be specialized as teacher, student, or a staff, based
on what role they play in school as entities.
3. Inheritance: We use all the above features of ER-Model in order to create classes of objects
in object-oriented programming. The details of entities are generally hidden from the user; this
process known as abstraction.
Inheritance is an important feature of Generalization and Specialization. It allows lower-level
entities to inherit the attributes of higher-level entities.
For example, the attributes of a Person class such as name, age, and gender can be inherited by
lower-level entities such as Student or Teacher.
4. Sub Class and Super Class: Sub class and Super class relationship leads the concept of
Inheritance. The relationship between sub class and super class is denoted with symbol.
Super Class: Super class is an entity type that has a relationship with one or more
subtypes.An entity cannot exist in database merely by being member of any super class.
For example: Shape super class is having sub groups as Square, Circle, Triangle.
2
Database Management System Unit-2: Relational Model
Sub Class: Sub class is a group of entities with unique attributes.Sub class inherits
properties and attributes from its super class. For example: Square, Circle, Triangle are the sub
class of Shape super class.
5. Category or Union: Category represents a single super class or sub class relationship with
more than one super class. It can be a total or partial participation. example Car booking, Car
owner can be a person, a bank (holds a possession on a Car) or a company. Category (sub class)
→ Owner is a subset of the union of the three super classes → Company, Bank, and Person. A
Category member must exist in at least one of its super classes.
3
Database Management System Unit-2: Relational Model
Rule-01: For Strong Entity Set With Only Simple Attributes: A strong entity set with only
simple attributes will require only one table in relational model.
Attributes of the table will be the attributes of the entity set.
The primary key of the table will be the key attribute of the entity set.
First-Name Last-Name
Rule-03: For Strong Entity Set With Multi Valued Attributes: A strong entity set with any
number of multi valued attributes will require two tables in relational model.
One table will contain all the simple attributes with the primary key.
Other table will contain the primary key and all the multi valued attributes.
Roll_no city
Roll_no Mobile-no
Rule-04: Translating Relationship Set into a Table- A relationship set will require one table
in the relational model. Attributes of the table are
Primary key attributes of the participating entity sets
Its own descriptive attributes if any.
Set of non-descriptive attributes will be the primary key.
4
Database Management System Unit-2: Relational Model
Rule-05: For Binary Relationships With Cardinality Ratios: The following four cases are
possible
Case-01: Binary relationship with cardinality ratio m:n : in this case separate table for
relationship will be required which will include the attributes which describe the identity of
relation entities i.e. primary key from both entities.
Case-02: For Binary Relationship With Cardinality Ratio 1:n: in this case separate table for
relationship is not required. The table for Relationship can be merged with entity having many
relation. For binary relationship with cardinality ratio either m : 1 or 1 : n , always remember
“many side will consume the relationship” i.e. a combined table will be drawn for many side
entity set and relationship set. Here, combined table will be drawn for the entity set B and
relationship set R.
Case-03: For Binary Relationship With Cardinality Ratio m:1: in this case separate table for
relationship is not required. The table for Relationship can be merged with entity having many
relation. For binary relationship with cardinality ratio either m : 1 or 1 : n , always remember
“many side will consume the relationship” i.e. a combined table will be drawn for many side
entity set and relationship set. Here, combined table will be drawn for the entity set A and
relationship set R.
5
Database Management System Unit-2: Relational Model
Case-04: For Binary Relationship With Cardinality Ratio 1:1 For binary relationship with
cardinality ratio 1 : 1 , two tables will be required. You can combine the relationship set with
any one of the entity sets. Here, two tables will be required. Either combine ‘R’ with ‘A’ or ‘B’
Way-01: AR ( a1 , a2 , b1 ) & B ( b1 , b2 )
Way-02: A ( a1 , a2 ) & BR ( a1 , b1 , b2 )
Rule-06: For Binary Relationship With Both Cardinality Constraints and Participation
Constraints:
Cardinality constraints will be implemented as discussed in Rule-05.
Because of the total participation constraint, foreign key acquires NOT NULL constraint i.e.
now foreign key cannot be null.
Case-01: For Binary Relationship With Cardinality Constraint and Total Participation
Constraint From One Side
Because cardinality ratio = 1 : n , so we will combine the entity set B and relationship set R.
Because of total participation, foreign key a1 has acquired NOT NULL constraint, so it can’t be
null now.
Case-02: For Binary Relationship With Cardinality Constraint and Total Participation
Constraint From Both Sides:
If there is a key constraint from both the sides of an entity set with total participation, then
that binary relationship is represented using only single table.
6
Database Management System Unit-2: Constraints & Normalization
Rule-07: For Binary Relationship With Weak Entity Set-: Weak entity set always appears in
association with identifying relationship with total participation constraint.
7
Database Management System Unit-2: Constraints & Normalization
8
Database Management System Unit-2: Constraints & Normalization
Rule 12: Non-Subversion Rule: If a system has an interface that provides access to low-level
records, then the interface must not be able to subvert the system and bypass security and
integrity constraints.
1. Domain constraints: Domain constraints can be defined as the definition of a valid set of
values for an attribute. The data type of domain includes string, character, integer, time, date,
currency, etc. The value of the attribute must be available in the corresponding domain.
Attributes have specific values in real-world scenario. For example, age can only be a positive
integer. The same constraints have been tried to employ on the attributes of a relation. Every
attribute is bound to have a specific range of values. For example, age cannot be less than zero
and telephone numbers cannot contain a digit outside 0-9.
Example:
2. Entity integrity constraints: The entity integrity constraint states that primary key value
can't be null. This is because the primary key value is used to identify individual rows in
relation and if the primary key has a null value, then we can't identify those rows. A table can
contain a null value other than the primary key field.
Example:
9
Database Management System Unit-2: Constraints & Normalization
3. Key constraints: Keys are the entity set that is used to identify an entity within its entity
set uniquely. An entity set can have multiple keys, but out of which one key will be the
primary key. A primary key can contain a unique and null value in the relational table. Example:
10
Database Management System Unit-2: Constraints & Normalization
Above is a simple example of a schema diagram. It shows three tables, along with their data
types, relationships between the tables, as well as their primary keys and foreign keys.
11
Database Management System Unit-2: Constraints & Normalization
2.7 ANOMALIES: If a database design is not perfect, it may contain anomalies that is impurity,
which are like a bad dream for any database administrator. Managing a database with
anomalies is next to impossible.
Update anomalies − If data items are scattered and are not linked to each other properly,
then it could lead to strange situations. For example, when we try to update one data item
having its copies scattered over several places, a few instances get updated properly while a
few others are left with old values. Such instances leave the database in an inconsistent state.
Deletion anomalies − We tried to delete a record, but parts of it was left undeletedbecause
of unawareness, the data is also saved somewhere else.
Insert anomalies − We tried to insert data in a record that does not exist at all.
12
Database Management System Unit-2: Constraints & Normalization
redundancy.
1. Lossless Decomposition: If the information is not lost from the relation that is
decomposed, then the decomposition will be lossless. The lossless decomposition guarantees
that the join of relations will result in the same relation as it was decomposed. The relation is
said to be lossless decomposition if natural joins of all the decomposition give the original
relation.
Example: Table: Employee_Department
The above relation is decomposed into two relations Employee and Department
Now, when these two relations are joined on the common column "EMP_ID", then the
resultant relation will look like: Employee X Department (Joint of Both Tables)
Here columns COLOR and MANUF_YEAR are dependent on BIKE_MODEL and independent of
each other. In this case, these two columns can be called as multivalued dependent on
BIKE_MODEL. The representation of these dependencies is shown below:
1. BIKE_MODEL → → MANUF_YEAR
2. BIKE_MODEL → → COLOR
So to remove this dependency the above table need to be decomposed in to two tables as
bellow.
This can be read as "BIKE_MODEL multi determined MANUF_YEAR" and "BIKE_MODEL multi
determined COLOR".
15