Relational Model
Relational Model
The relational Model of Data is based on the concept of a Relation. In Relational model, data are stored
in the table format. It is a primary data model, which is used widely around the world for commercial
data storage and processing applications. This model is simple but it provides powerful way to process,
represent and store data with efficiency. It also supports complex query. The relational model consists of
three major components:
1. The set of relations and set of domains that defines the way data can be represented (data
structure).
2. Integrity rules that define the procedure to protect the data (data integrity).
3. The operations that can be performed on data (data manipulation).
Domain:
A domain definition specifies the kind of data represented by the attribute. It specifies that within each
tuple, the value of each attribute must be an atomic value. By atomic, we mean that each value in the
domain is indivisible as far as the formal definition is concerned.
If D is the domain of an attribute A which takes its values then it is denoted by dom(A).
Tuple:
A single row of a table, which contains a single record for that relation, is called a tuple.
Attribute:
A column of a table, which describes the relation, is called an attribute. Each attribute is associated with a
domain.
Relation:
A relation is defined as a table of values. It can be thought as a set of rows. It can also be alternatively
though as a set of columns.
A relation can also be defined as a subset of the Cartesian product of a list of domains characterized by a
name.
If D1, D2, ……, Dn are n domains, then the relation R on these domains is mathematically defined as:
R ⊆ D1X D2 X ……… X Dn
Relation Schema:
A relation schema is used to describe a relation. It describes the relation name (table name), attributes,
and their names.
Relation instance:
A finite set of tuples in the relational database system represents relation instance. Relation instances do
not have duplicate tuples.
A relation schema or relation scheme R, denoted R (A1, A2, …., An), is made up of a relation name R
and a list of attributes A1, A2, .. . An
Cardinality of a relation:
The number of tuples in a relation determines its cardinality.
Degree of a relation:
The degree of the relation is the number of attributes n of its relation schema. Each column in the tuple is
called an attribute. The number of attributes in a relation determines its degree.
Example:
Here,
Relation: STUDENT is the relation name.
Attributes: Name, Ssn, Home_phone, Address, Office_phone, Age and Gpa are attributes.
Adding the data type of each attribute, the definition is sometimes written as:
STUDENT(Name:string, Ssn:string, Home_phone:string, Address:string, Office_Phone:string,
Age:integer, Gpa:real)
Domain: dom(Name)= Names; dom(Ssn)= Social_security_numbers; dom(HomePhone)=
USA_phone_numbers, etc. are domains the cossecponding attribute.
Tuple: All data entries are Tuples.
Relation Schema: STUDENT (Name, Ssn, Home_phone, Address, Office_Phone, Age, Gpa)
Relation Instance:
Cardinality: In this case, the relation has a cardinality of 5.
Degree: In this case, the relation has a degree of 7.
Characteristics of a Relation:
a) Ordering of tuples in a relation:
The tuples are not considered to be ordered, even though they appear to be in the tabular form. A
relation is defined as a set of tuples. Mathematically, the elements of a set have no order; hence
tuples in a particular relation have no particular order. Tuple ordering is not part of the relation.
b) Ordering of Values in a tuple and an Alternative definition of a relation:
The order of values of a tuple can be changed as long as the correspondence between attributes
and values is maintained. If we consider attributes in R (A1, A2, ..., An) then the values in
t=<v1,v2, ..., vn> should correspond the order of the attributes.
c) Values in a tuple:
All values are considered atomic (indivisible). A special null value is used to represent values that
are unknown or inapplicable to certain tuples.
Interpretation of a Relation:
The relation schema can be interpreted as a declaration or an assertion. Some relations may represent
facts about entities, whereas other relations may represent facts about relationships. For example a
relation STUDENT, represents facts about a student entity. However a relation MAJORS(Student_Ssn,
Department_code) asserts that a student majors in an academic discipline. A tuple in this relation relates a
student to the department in which the major is offered.
Domain Constraints:
Domain constraints specify that within each tuple, the value of each attribute A must be an atomic value
from the domain dom(A). The data types associated with domains include standard numeric datatypes for
integers, real numbers, characters, strings, Booleans. Also are available dates, time, money , a subrange
of values from a data type, or an enumerated data type in which all valid values are explicitly listed.
Key Constraints:
In the formal relational model, a relation is defined as a set of tuples. And all elements in a must be
distinct. This is maintained by the key constraints.
Some different types of keys are:
Super Key
Composite Key
Candidate Key
Primary Key
Secondary/Alternate Key
Foreign Key