Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

Relational Model in DBMS

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

The relational Model was proposed by E.F. Codd to model data in the form of relations or tables. After designing the conceptual model of the Database using ER diagram, we need to convert the conceptual model into a relational model which can be implemented using any RDBMS language like Oracle SQL, MySQL, etc. So we will see what the Relational Model is.

What is the Relational Model? 

The relational model represents how data is stored in Relational Databases. A relational database consists of a collection of tables, each of which is assigned a unique name. Consider a relation STUDENT with attributes ROLL_NO, NAME, ADDRESS, PHONE, and AGE shown in Table 1. 

STUDENT 

ROLL_NONAMEADDRESSPHONEAGE
1RAMDELHI945512345118
2RAMESHGURGAON965243154318
3SUJITROHTAK915625313120
4SURESHDELHI 18

 IMPORTANT TERMINOLOGIES

  • Attribute: Attributes are the properties that define an entity. e.g.; ROLL_NO, NAME, ADDRESS
  • Relation Schema: A relation schema defines the structure of the relation and represents the name of the relation with its attributes. e.g.; STUDENT (ROLL_NO, NAME, ADDRESS, PHONE, and AGE) is the relation schema for STUDENT. If a schema has more than 1 relation, it is called Relational Schema.
  • Tuple: Each row in the relation is known as a tuple. The above relation contains 4 tuples, one of which is shown as:
1RAMDELHI945512345118
  • Relation Instance: The set of tuples of a relation at a particular instance of time is called a relation instance. Table 1 shows the relation instance of STUDENT at a particular time. It can change whenever there is an insertion, deletion, or update in the database.
  • Degree: The number of attributes in the relation is known as the degree of the relation. The STUDENT relation defined above has degree 5.
  • Cardinality: The number of tuples in a relation is known as cardinality. The STUDENT relation defined above has cardinality 4.
  • Column: The column represents the set of values for a particular attribute. The column ROLL_NO is extracted from the relation STUDENT.
ROLL_NO
1
2
3
4
  • NULL Values: The value which is not known or unavailable is called a NULL value. It is represented by blank space. e.g.; PHONE of STUDENT having ROLL_NO 4 is NULL. 

Constraints in Relational Model

While designing the Relational Model, we define some conditions which must hold for data present in the database are called Constraints. These constraints are checked before performing any operation (insertion, deletion, and updation ) in the database. If there is a violation of any of the constraints, the operation will fail. 

Domain Constraints: These are attribute-level constraints. An attribute can only take values that lie inside the domain range. e.g; If a constraint AGE>0 is applied to STUDENT relation, inserting a negative value of AGE will result in failure. 

Key Integrity: Every relation in the database should have at least one set of attributes that defines a tuple uniquely. Those set of attributes is called keys. e.g.; ROLL_NO in STUDENT is a key. No two students can have the same roll number. So a key has two properties: 

  • It should be unique for all tuples.
  • It can’t have NULL values.

Referential Integrity: When one attribute of a relation can only take values from another attribute of the same relation or any other relation, it is called referential integrity. Let us suppose we have 2 relations 

STUDENT 

ROLL_NONAMEADDRESSPHONEAGEBRANCH_CODE
1RAMDELHI945512345118CS
2RAMESHGURGAON965243154318CS
3SUJITROHTAK915625313120ECE
4SURESHDELHI 18IT

 BRANCH 

BRANCH_CODEBRANCH_NAME
CSCOMPUTER SCIENCE
ITINFORMATION TECHNOLOGY
ECEELECTRONICS AND COMMUNICATION ENGINEERING
CVCIVIL ENGINEERING

BRANCH_CODE of STUDENT can only take the values which are present in BRANCH_CODE of BRANCH which is called referential integrity constraint. The relation which is referencing another relation is called REFERENCING RELATION (STUDENT in this case) and the relation to which other relations refer is called REFERENCED RELATION (BRANCH in this case). 
 

ANOMALIES

An anomaly is an irregularity or something which deviates from the expected or normal state. When designing databases, we identify three types of anomalies: Insert, Update and Delete. 

Insertion Anomaly in Referencing Relation: 

We can’t insert a row in REFERENCING RELATION if referencing attribute’s value is not present in the referenced attribute value. e.g.; Insertion of a student with BRANCH_CODE ‘ME’ in STUDENT relation will result in an error because ‘ME’ is not present in BRANCH_CODE of BRANCH. 

Deletion/ Updation Anomaly in Referenced Relation: 

We can’t delete or update a row from REFERENCED RELATION if the value of REFERENCED ATTRIBUTE is used in the value of REFERENCING ATTRIBUTE. e.g; if we try to delete a tuple from BRANCH having BRANCH_CODE ‘CS’, it will result in an error because ‘CS’ is referenced by BRANCH_CODE of STUDENT, but if we try to delete the row from BRANCH with BRANCH_CODE CV, it will be deleted as the value is not been used by referencing relation. It can be handled by the following method: 

ON DELETE CASCADE: It will delete the tuples from REFERENCING RELATION if the value used by REFERENCING ATTRIBUTE is deleted from REFERENCED RELATION. e.g; For, if we delete a row from BRANCH with BRANCH_CODE ‘CS’, the rows in STUDENT relation with BRANCH_CODE CS (ROLL_NO 1 and 2 in this case) will be deleted. 

ON UPDATE CASCADE: It will update the REFERENCING ATTRIBUTE in REFERENCING RELATION if the attribute value used by REFERENCING ATTRIBUTE is updated in REFERENCED RELATION. e.g;, if we update a row from BRANCH with BRANCH_CODE ‘CS’ to ‘CSE’, the rows in STUDENT relation with BRANCH_CODE CS (ROLL_NO 1 and 2 in this case) will be updated with BRANCH_CODE ‘CSE’. 

SUPER KEYS: 
Any set of attributes that allows us to identify unique rows (tuples) in a given relationship is known as super keys. Out of these super keys, we can always choose a proper subset among these which can be used as a primary key. Such keys are known as Candidate keys. If there is a combination of two or more attributes that are being used as the primary key then we call it a Composite key. 
 

Advantages:

  • Simple model
  • It is Flexible
  • It is Secure
  • Data accuracy
  • Data integrity
  • Operations can be applied easily

Disadvantage:

  • Not good for large database
  • Relation between tables become difficult some time

Characteristics of Relational Model:

  • Data is represented into rows and columns called as relation.
  • Data is stored in tables having relationship between them called Relational model.
  • Relational model supports the operations like Data definition, Data manipulation, Transaction management.
  • Each column have distinct name and they are representing attribute.
  • Each row represents the single entity.

Basic Operators in Relational Algebra 
Article Contributed by Sonal Tuteja. Please write comments if you find anything incorrect, or if you want to share more information about the topic discussed above
 


My Personal Notes arrow_drop_up
Last Updated : 12 May, 2023
Like Article
Save Article
Similar Reads