What is Relational Model?
Relational Model (RM) represents the database as a collection of relations. A relation is nothing but a
table of values. Every row in the table represents a collection of related data values. These rows in the
table denote a real-world entity or relationship.
The table name and column names are helpful to interpret the meaning of values in each row. The data are
represented as a set of relations. In the relational model, data are stored as tables. However, the physical
storage of the data is independent of the way the data are logically organized.
Advantages of Realation Model
Structural Independence: Structural independence is an ability that allows us to make changes in
one database structure without affecting other. The relational model have structural
independence. Hence making required changes in the database is convenient in relational
database model.
Conceptual Simplicity: The relational model allows the designer to simply focus on logical
design and not on physical design. Hence relational models are conceptually simple to
understand.
Query Capability: Using simple query language (such as SQL) user can get information from the
database or designer can manipulate the database structure.
Easy design,maintenance and usage: The relational models can be designed logically hence they
are easy to maintain and use.
Disadvantages of Realation Model
Relational model requires powerful hardware and large data storage devices.
May lead to slower processing time.
Poorly designed systems lead to poor implementation of database systems.
Let us count points to understand the relational model in short:
The database is a set of related relations (table of values).
Each relation has a name which indicates what type of tuples the relation has. For example, a
relation named ‘Student’ indicates that it has student entities in it.
Each relation has a set of attributes (column names) which represents, what type of information,
the entities or tuples have? For example, Student relation has a set of attributes Roll_No., Name,
Department. It indicates that the Student relation has student entities/tuples that have information
about their roll_no., name and department.
A tuple (row) in a relation, is a real-world entity, it has a set of values for corresponding
attributes.
Each data value in a row or tuple is called field.
Relational Model Diagram
The figure below indicates a relation in a relational model.
It is a Student relation and it is having entries of 5 students (tuples) in it. The figure below will help you
identify the relation, attributes, tuples and field in a relational model.
Characteristics of Relational Database Model
As we know we have several relations in a database. Now, each relation must be uniquely identified. If it
is not so, then it would create a lot of confusion. Here, we will discuss some characteristics that when
followed will automatically make a relation distinct in a database.
1. Each relation in a database must have a distinct or unique name which would separate it from the other
relations in a database.
2. A relation must not have two attributes with the same name. Each attribute must have a distinct name.
3. Duplicate tuples must not be present in a relation.
4. Each tuple must have exactly one data value for an attribute. For example, below in the first table, you
can see that for Roll_No. 265 we have enrolled two students Jhoson and Charles, this would not work.
We must have only one student for one Roll_No.
5. Tuples in a relation do not have to follow a significant order as the relation is not order-sensitive.
6. Similarly, the attributes of a relation also do not have to follow certain ordering, it’s up to the developer
to decide the ordering of attributes.
Properties of Relational Tables
Values Are Atomic
This property implies that columns in a relational table are not repeating group or arrays. Such tables are
referred to as being in the "first normal form" (1NF). The atomic value property of relational tables is
important because it is one of the cornerstones of the relational model.
The key benefit of the one value property is that it simplifies data manipulation logic.
Column Values Are of the Same Kind
In relational terms this means that all values in a column come from the same domain. A domain is a set
of values which a column may have. For example, a Monthly_Salary column contains only specific
monthly salaries. It never contains other information such as comments, status flags, or even weekly
salary.
This property simplifies data access because developers and users can be certain of the type of data
contained in a given column. It also simplifies data validation. Because all values are from the same
domain, the domain can be defined and enforced with the Data Definition Language (DDL) of the
database software.
Each Row is Unique
This property ensures that no two rows in a relational table are identical; there is at least one column, or
set of columns, the values of which uniquely identify each row in the table. Such columns are called
primary keys and are discussed in more detail in Relationships and Keys.
This property guarantees that every row in a relational table is meaningful and that a specific row can be
identified by specifying the primary key value.
The Sequence of Columns is Insignificant
This property states that the ordering of the columns in the relational table has no meaning. Columns can
be retrieved in any order and in various sequences. The benefit of this property is that it enables many
users to share the same table without concern of how the table is organized. It also permits the physical
structure of the database to change without affecting the relational tables.
The Sequence of Rows is Insignificant
This property is analogous the one above but applies to rows instead of columns. The main benefit is that
the rows of a relational table can be retrieved in different order and sequences. Adding information to a
relational table is simplified and does not affect existing queries.
Each Column Has a Unique Name
Because the sequence of columns is insignificant, columns must be referenced by name and not by
position. In general, a column name need not be unique within an entire database but only within the table
to which it belongs.
Relational Model concepts in DBMS
Relational database concepts to understand in DBMS include:
Attribute: An attribute is a characteristic or quality of an entity. In the context of the relational
model, an attribute is a column in a table.
Tables: A table is a data collection organized into rows and columns. In the relational model for
database management, tables are used to store information about entities.
Tuple: A tuple is a row in a table. Tuples are composed of attributes.
Relation Schema: A relation schema is a blueprint for a table. It defines the attributes that are
contained in a table as well as the relationships between those attributes.
Degree: The degree is the number of attributes that it contains.
Cardinality: Cardinality defines the relationship between two attributes in a relation schema.
There are three possible relationships: one-to-one, one-to-many, and many-to-many.
Column: A column is an attribute that is contained in a table. Columns are also sometimes
referred to as fields.
Relation instance: A relation instance is a set of tuples that conforms to a given relation schema.
In other words, it is populated data that has been organized into rows and columns according to
the blueprint set forth by a relation schema.
Relation key: A relation key is an attribute or combination of attributes that uniquely identifies a
tuple in a table.
Domain: The domain of an attribute is the set of values that can be stored in that attribute. For
example, if an attribute represents ages, its domain would be any age from 0 onward.
Integrity constraint
Integrity constraints are a set of rules. It is used to maintain the quality of information.
Integrity constraints ensure that the data insertion, updating, and other processes have to be
performed in such a way that data integrity is not affected.
Thus, integrity constraint is used to guard against accidental damage to the database.
Types of Integrity Constraint
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.
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:
3. Referential Integrity Constraints
A referential integrity constraint is specified between two tables.
In the Referential integrity constraints, if a foreign key in Table 1 refers to the Primary Key of
Table 2, then every value of the Foreign Key in Table 1 must be null or be available in Table 2.
Example:
4. 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: