Open In App

Introduction of Relational Model and Codd Rules in DBMS

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Share
Report issue
Report

Pre-Requisite: Relational Model in DBMS

It was proposed by Dr. E.F. Codd. It uses the concept of relations to represent each and every file. Relations are Two-Dimensional Tables. It is easy to implement and easy to simplification in the operations to manipulate the data. This is the most popular data model. It is simple to implement. It uses the primary key and secondary key to connect any two files. Normalization Theory is used to design the object-based data model. Relational Algebra and Relational Calculus are used to process the relations manually. Many database languages are oriented toward handling relational data models. A Relational Database Model consists of relations to connect them by key fields. A relation has some attributes. The relation is represented in rows and columns. Each column of the relation is called an attribute. Each row in the relation is called a tuple. Each relation can have one unique column i.e. primary key. Each relation can have n-columns and n-tuple. Each relation is preceded by the name of that relation. The fields of the relations are separated by commas and placed within the parentheses of the relation. The relational model represents data in the form of relations or tables.

Example: Relational Model can be represented as shown below

STUDENT (StudNo, Sname, Special)
ENROLLMENT (StudNo, Subcode, marks)
SUBJECT (Subcode, Subname, Maxmarks, Faccode)
FACULTY (Faccode, Fname, Dept)

 Terminologies 

Relational Schema: Schema represents the structure of a relation.                                                                                                         

Example: Relational Schema of STUDENT relation can be represented as STUDENT(STUD_NO, STUD_NAME,  STUD_PHONE, STUD_STATE, STUD_COUNTRY, STUD_AGE).

Relational Instance: The set of values present in a relationship at a particular instance of time is known as a relational instance as shown in Table 1 and Table 2. 

Attribute: Each relation is defined in terms of some properties, each of which is known as an attribute.  

Example: STUD_NO, STUD_NAME, etc. are attributes of relation STUDENT. 

The domain of an attribute: The possible values an attribute can take in a relation is called its domain. 

Example: domain of STUD_AGE can be from 18 to 40. 

Tuple: Each row of a relation is known as a tuple.                                                                                                                                      

Example: STUDENT relation given below has 4 tuples. 

NULL values: Values of some attribute for some tuples may be unknown, missing, or undefined which are represented by NULL. Two NULL values in a relationship are considered different from each other. Table 1 and Table 2 represent the relational model having two relations STUDENT and STUDENT_COURSE. 

STUDENT TABLE

STUD_NO STUD_NAME STUD_PHONE STUD_STATE STUD_COUNTRY STUD_AGE
1 RAM 9716271721 Haryana India 20
2 RAM 9898291281 Punjab India 19
3 SUJIT 7898291981 Rajasthan India 18
4 SURESH 9985286317 Punjab India 21

STUDENT COURSE TABLE

STUD_NO                       COURSE_NO                   COURSE_NAME                     
1 C1 DBMS
2 C2 Computer Networks
1 C2 Computer Networks

RDBMS Vendors

There are several vendors that offer Relational Database Management Systems (RDBMS). Here are some of the most popular ones:

Oracle: Oracle Database is one of the most widely used RDBMS products in the market. It is known for its robustness, scalability, and reliability. It is used by many large enterprises and is particularly well-suited for data warehousing and transaction processing.

Microsoft: Microsoft SQL Server is a popular RDBMS used in Windows environments. It offers a range of features, including data mining, business intelligence, and reporting services.

IBM: IBM DB2 is a popular RDBMS used in enterprise environments. It offers high availability, disaster recovery, and scalability features.

MySQL: MySQL is an open-source RDBMS used by many small to medium-sized businesses. It is known for its ease of use, flexibility, and low cost.

PostgreSQL: PostgreSQL is another popular open-source RDBMS. It is known for its scalability, reliability, and support for complex transactions.

SAP: SAP HANA is an in-memory RDBMS that is designed for high-performance analytics and data processing. It is often used in enterprise environments for real-time reporting and business intelligence.

Relational Algebra

It is a procedural Language. It consists of a set of operators that can be performed on relations. Relational Algebra forms the basis for many other high-level data sub-languages like SQL and QBE
 Relational algebra has mainly 9 types of operators.

1. UNION (U): A and B are two relations. It displays total values (Attributes) in both relations. It avoids duplicate values in both relations. U symbol can be used.
 

Syntax: 

A UNION B (or) A U B
 

Example:

 A = { clerk, manager, salesman}
B = { president, clerk, manager}
A UNION B = {clerk, manager, salesman, president}

2. INTERSECTION (∩): A and B are two relations. It displays common elements in both relations. “∩” symbol can be used.
 

Syntax: 

A INTERSECT B (or) A ∩ B

Example: 

A = { clerk, manager, salesman}
B = { president, clerk, manager}
A INTERSECT B = { clerk, manager}

3. DIFFERENCE (─): A and B are two relations. It displays elements in relation A not in relation B. 
 

Syntax: 

A MINUS B (OR) A ─ B

Example:

A = { clerk, manager, salesman}
B = { president, clerk, manager}
A MINUS B = {salesman}

4. CARTESIAN PRODUCT(X): A and B are two relations. It has a new relation consisting of all pair wises combinations of all elements in A and B. The relation A has “m” elements and relation B has “n” elements, then the resultant relation will be “ m * n “. 
 

Syntax: 

A TIMES B (OR) A X B

Example: 

A = { clerk, manager, salesman}
B = { president, clerk, manager}
A TIMES B = { (clerk, president),
(clerk, clerk),(clerk, manager),
(manager, president), (manager, clerk),
(manager, manager),(salesman, president), 
(salesman, clerk), (salesman, manager) }

5. SELECTION (σ): It displays all the attributes or columns of all the rows in a relation. “” operator can be used to select the attributes in a relation.

The  select operation 

In general SELECT operation is denoted by

(σ)(R)

(σ)(Sigma): SELECT operator

 θ: Selection condition

R: Relation or relational algebra expression.

In general the select condition is a Boolean condition (i.e. an expression using logical connective) of terms that have the form attribute OP constant 1 OP attribute2 where OP is the comparison operators <,>,=,>= etc.
Syntax: 

σ condition (relation name) 

6. PROJECTION (π): It displays some specified columns in a relation. “π” operator can be used to select some specified columns in a relation. It selects tuples that satisfy the given predicate from a relation. It displays some specified columns by using some conditions.

Syntax:

Syntax: π(col1,col2…) Relation Name

Example: 

π(sno, sname, total) MARKS

7. JOIN( ): It combines two or more relations. Symbols can be used. It can be mainly divided into mainly 4 types. These are mainly

8. DIVIDE (÷): It divides the tuple from one relation to another relation
 

Syntax: 

A DIVIDE B (OR) A ÷ B

Example: 

A = { clerk, manager, salesman} 
B = { clerk, manager}
A DIVIDE B = {salesman}

9. RENAME(ρ): It gives another name to the relation.
 

Syntax: 

ρ(OLD RELATION, NEW RELATION)

Example: 

ρ(STUDENT, MARKS)
It changes the “student” relation to “Marks” relation.
It also renames the specified column.
It changes the old-column name to new-column name.

Features of the relational model and Codd’s Rules :

Tables/Relations: The basic building block of the relational model is the table or relation, which represents a collection of related data. Each table consists of columns, also known as attributes or fields, and rows, also known as tuples or records.

Primary Keys: In the relational model, each row in a table must have a unique identifier, which is known as the primary key. This ensures that each row is unique and can be accessed and manipulated easily.

Foreign Keys: Foreign keys are used to link tables together and enforce referential integrity. They ensure that data in one table is consistent with data in another table.

Normalization: The process of organizing data into tables and eliminating redundancy is known as normalization. Normalization is important in the relational model because it helps to ensure that data is consistent and easy to maintain.

Codd’s Rules: Codd’s Rules are a set of 12 rules that define the characteristics of a true relational DBMS. These rules ensure that the DBMS is consistent, reliable, and easy to use.

Atomicity, Consistency, Isolation, Durability (ACID): The ACID properties are a set of properties that ensure that transactions are processed reliably in the relational model. Transactions are sets of operations that are executed as a single unit, ensuring that data is consistent and accurate.

Advantages of Relational Algebra

Relational Algebra is a formal language used to specify queries to retrieve data from a relational database. It has several advantages that make it a popular choice for managing and manipulating data. Here are some of the advantages of Relational Algebra:

Simplicity: Relational Algebra provides a simple and easy-to-understand set of operators that can be used to manipulate data. It is based on a set of mathematical concepts and principles, which makes it easy to learn and use.

Formality: Relational Algebra is a formal language that provides a standardized and rigorous way of expressing queries. This makes it easier to write and debug queries, and also ensures that queries are correct and consistent.

Abstraction: Relational Algebra provides a high-level abstraction of the underlying database structure, which makes it easier to work with large and complex databases. It allows users to focus on the logical structure of the data, rather than the physical storage details.

Portability: Relational Algebra is independent of any specific database management system, which means that queries can be easily ported to other systems. This makes it easy to switch between different databases or vendors without having to rewrite queries.

Efficiency: Relational Algebra is optimized for efficiency and performance, which means that queries can be executed quickly and with minimal resources. This is particularly important for large and complex databases, where performance is critical.

Extensibility: Relational Algebra provides a flexible and extensible framework that can be extended with new operators and functions. This allows developers to customize and extend the language to meet their specific needs.

Disadvantages of Relational Algebra

While Relational Algebra has many advantages, it also has some limitations and disadvantages that should be considered when using it. Here are some of the disadvantages of Relational Algebra:

Complexity: Although Relational Algebra is based on mathematical principles, it can be complex and difficult to understand for non-experts. The syntax and semantics of the language can be challenging, and it may require significant training and experience to use it effectively.

Limited Expressiveness: Relational Algebra has a limited set of operators, which can make it difficult to express certain types of queries. It may be necessary to use more advanced techniques, such as subqueries or joins, to express complex queries.

Lack of Flexibility: Relational Algebra is designed for use with relational databases, which means that it may not be well-suited for other types of data storage or management systems. This can limit its flexibility and applicability in certain contexts.

Performance Limitations: While Relational Algebra is optimized for efficiency and performance, it may not be able to handle large or complex datasets. Queries can become slow and resource-intensive when dealing with large amounts of data or complex queries.

Limited Data Types: Relational Algebra is designed for use with simple data types, such as integers, strings, and dates. It may not be well-suited for more complex data types, such as multimedia files or spatial data.

Lack of Integration: Relational Algebra is often used in conjunction with other programming languages and tools, which can create integration challenges. It may require additional programming effort to integrate Relational Algebra with other systems and tools.

Relational Algebra is a powerful and useful tool for managing and manipulating data in relational databases, it has some limitations and disadvantages that should be carefully considered when using it.

Codd’s Twelve Rules of Relational Database

Codd rules were proposed by E.F. Codd which should be satisfied by the relational model. Codd’s Rules are basically used to check whether DBMS has the quality to become Relational Database Management System (RDBMS). But, it is rare to find that any product has fulfilled all the rules of Codd. They generally follow the 8-9 rules of Codd. E.F. Codd has proposed 13 rules which are popularly known as Codd’s 12 rules. These rules are stated as follows:

  • Rule 0: Foundation Rule– For any system that is advertised as, or claimed to be, a relational database management system, that system must be able to manage databases entirely through its relational capabilities.
  • Rule 1: Information Rule– Data stored in the Relational model must be a value of some cell of a table.
  • Rule 2: Guaranteed Access Rule– Every data element must be accessible by the table name, its primary key, and the name of the attribute whose value is to be determined.
  • Rule 3: Systematic Treatment of NULL values– NULL value in the database must only correspond to missing, unknown, or not applicable values.
  • Rule 4: Active Online Catalog– The structure of the database must be stored in an online catalog that can be queried by authorized users.
  • Rule 5: Comprehensive Data Sub-language Rule- A database should be accessible by a language supported for definition, manipulation, and transaction management operation.
  • Rule 6: View Updating Rule- Different views created for various purposes should be automatically updatable by the system.
  • Rule 7: High-level insert, update and delete rule- Relational Model should support insert, delete, update, etc. operations at each level of relations. Also, set operations like Union, Intersection, and minus should be supported.
  • Rule 8: Physical data independence- Any modification in the physical location of a table should not enforce modification at the application level.
  • Rule 9: Logical data independence- Any modification in the logical or conceptual schema of a table should not enforce modification at the application level. For example, merging two tables into one should not affect the application accessing it which is difficult to achieve.
  • Rule 10: Integrity Independence- Integrity constraints modified at the database level should not enforce modification at the application level.
  • Rule 11: Distribution Independence- Distribution of data over various locations should not be visible to end-users.
  • Rule 12: Non-Subversion Rule- Low-level access to data should not be able to bypass the integrity rule to change data.

GATE Question

Given the basic ER and relational models, which of the following is INCORRECT?  [GATE CS 2012] 

  1. An attribute of an entity can have more than one value.
  2. An attribute of an entity can be a composite.
  3. In a row of a relational table, an attribute can have more than one value. 
  4. In a row of a relational table, an attribute can have exactly one value or a NULL value. 

Answer: In the relation model, an attribute can’t have more than one value. So, option 3 is the answer.



Last Updated : 03 Aug, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads