Relational Data Model
Introduction:
Relational data model developed by E.F. Codd helps to
convert conceptual model into relational model using languages such as SQL,
MySQL, Oracle.
In relational model, tables are used to represent both
data and relationship among the data. Tables in relational models are known as
relations.
Today it is one of the majorly used database model and
majority of database system uses this model.
It contains different attributes. For example the employee
table have attributes such as E_id, name, address, phone
no, age etc. As shown in the table below.
Employee Table
There are important terms that are used in database
model. These are as follows:
Attribute: These are the
property that defines an entity such as E_id, name, phone no.
Tuple: Row in a relation(Table) is known as tuple. For
example in the above table there are 5 tuples.
Relation
instance: the set of tuples
of a relation at a particular instance is called a relation instance. For
example in the above relation there is instance of employee at a particular
instance it will change whenever there is deletion, updation or insertion in
the database.
Degree: The number of attributes in a relation is known as
degree. For example in the above table attributes are E-id, Name, address,
phone no. age
Cardinality: Number of tuples in a relation is known as
cardinality. In the above table the cardinality is 5.
Column: it represents the set of values of particular
attribute.
Relation keys: These are basically values that help in identifying
the rows uniquely in relations. There are basically four types of keys which
are as follows:
a. Primary
key: Primary key helps in uniquely identifying a
tuple in a relation. There is only one primary key in a relation and its value
can’t be NULL. In the employee table E_ID is the primary key.
b. Candidate
key: It is a set of
attributes which helps in uniquely identifying a tuple in a relation. It is a
minimal super key and a relation may contain more than one candidate key. Value
of candidate key can be NULL.
c. Super
key: It is a attribute
(or set of attributes) that is used to uniquely identifying all the attributes
in a relation. All super keys can’t be candidate key but all the candidate keys
are super keys.
d.
Foreign
key: It is attribute
that establishes a relation between two separate table.
Integrity
Constraints in Relational model
·
Constraints
are basically the conditions which must hold for presenting data in the
database table. Before performing operations in the database such as deletion, update, insertion these
constraints must be followed. Operation will fail if there is violation of the
constraints.
Types of Integrity Constraint
1. Domain constraint: This constraint is related to attributes of the
table. It means that an attributes of the table can take values inside the
domain range. For example: The name of an employee should be in characters it
any integer value is putted in name column then it will violate domain
constraint.
2. Entity Integrity constraint: This constraint is related to primary key of the table. It states that
there must be at least one attribute in the table that uniquely identifies the tuple.
It should be unique and not NULL for each tuple. For example in Employee table
E_id is the primary key.
3. Referential integrity constraints: it is related to foreign key. In this constraint one
attribute of a relation can only take values of the same relation or any other
relation.
Table employee
Department code of an employee can only take values
which are present in the Department code of the Department table. This is
called referential integrity.
1. Key constraints or Uniqueness constraints: Uniqueness constraint ensures that every tuple is unique in a table. It is related to candidate key. A relation can have more than one key or candidate keys (minimum superkey), from which one of the keys is selected as the primary key. There is no limit on the primary key to be selected from candidate keys. However, it is recommended to select the candidate key with fewer attributes.
Relational Data model MCQs Click here
R
0 Comments