Computer >> Computer tutorials >  >> Programming >> SQL

Relational Data Model


The relational data model is the most famous data model and is used by the majority around the world.This is a simple but efficient data model and has the capability to handle data in the best possible manner.

Tables are used to handle the data in the relational data model. An example of a table containing data about the Employees in a company is as follows −

<Employee>

Emp_Number
Emp_Name
Emp_Designation
Emp_Age
Emp_Salary
1
Jack
Manager
35
50000
2
Tom
Technician
25
25000
3
Henry
Secretary
50
30000


The table Employee has the following characteristics −

  • Tuple- A row of the table is called a tuple. It stores the data details according to the table schema.

  • Column- A column of the database represents the same form of data. Example - In the above database, Name represents names of all the employees.

  • Relational Schema - A relational schema defines the table name and its attributes. The schema for the above table would be Employee(Emp number, Name, Designation, Age, Salary)

  • Key- The key for a table is the attribute that can uniquely identify all the tuples. In the Employee table, the key is Emp Number as it is unique for every single employee,.

Constraints

Every relation has some constraints that must hold for it to be called a relational model. These are as followed −

  • Key constraints - There must be at least one set of attributes that can identify a tuple in a unique manner. This set is known as a key.
  • Domain constraints - There are some domain specific constraints that must be followed in a database. Example - The salary of an employee cannot be negative so the salary field has only positive values.
  • Referential Integrity constraints - These constraints are used to describe the behaviour of foreign keys. A foreign key is a key of a relation that can be referred in another relation.