0% found this document useful (0 votes)
16 views28 pages

Introduction of Relational Model and Codd Rules in DBMS

The document introduces the Relational Model in Database Management Systems (DBMS), emphasizing its organization of data into tables and the principles defined by Codd's Rules for true relational databases. It covers key features such as simplicity, linking through keys, normalization, and data processing methods, along with various SQL operations and joins. Additionally, it highlights the importance of primary and foreign keys, normalization, and ACID properties in ensuring data integrity and reliability.

Uploaded by

nirajhbiradar123
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views28 pages

Introduction of Relational Model and Codd Rules in DBMS

The document introduces the Relational Model in Database Management Systems (DBMS), emphasizing its organization of data into tables and the principles defined by Codd's Rules for true relational databases. It covers key features such as simplicity, linking through keys, normalization, and data processing methods, along with various SQL operations and joins. Additionally, it highlights the importance of primary and foreign keys, normalization, and ACID properties in ensuring data integrity and reliability.

Uploaded by

nirajhbiradar123
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Introduction of Relational Model and Codd Rules in DBMS

➢ The Relational Model is a fundamental concept in Database Management Systems (DBMS) that organizes data
into tables, also known as relations.
➢ This model simplifies data storage, retrieval, and management by using rows and columns.
➢ Codd’s Rules, introduced by Dr. Edgar F. Codd, define the principles a database must follow to qualify as a true
relational database.
➢ These tables are also called relations
Key features are as follows:

•Simplicity: Conveying simplicity in implementation, simplifies the operations that one will want to perform on data.

•Linking: It uses primary and secondary keys to interlink two files or tables.

•Normalization: It utilizes the concept of normalization theory for designing non-redundant and efficient object-

based data models.

•Data Processing: It utilizes Relational Algebra and Relational Calculus for manipulation of these relations. Many

database languages have been developed having special features for handling relational data models.
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.
WHERE Clause

The SQL WHERE clause filters rows based on one or more conditions, so your query returns (or modifies) only the
records that match. It’s used across SELECT, UPDATE, and DELETE statements, and works with data from a single
table or from multiple tables after joins.

SELECT Name, Department, Salary


FROM Employees
WHERE Salary > 50000;
Where Clause with Logical Operators

SELECT * FROM Emp1 WHERE Age=24;


WHERE with Comparison Operators
To fetch the EmpID, Name and Country of Employees with Age greater than 21.

SELECT EmpID, Name, Country FROM Emp1 WHERE Age > 21;

Where Clause with BETWEEN Operator


We want to find employees whose age is between 22 and 24, including both 22 and 24.
SELECT * FROM Emp1
WHERE Age BETWEEN 22 AND 24;
Where Clause with LIKE Operator
The '%'(wildcard) signifies the later characters here which can be of any length and value.

SELECT *
FROM Employee
WHERE Name LIKE 'L%';

Where Clause with IN Operator


Here we want to find the Names of Employees where Age is 21 or 23.

SELECT Name FROM Emp1 WHERE Age IN (21,23);


Operators Used in
WHERE Clause
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.
➢ UNION

➢ INTERSECTION

➢ MINUS

➢ TIMES

➢ SELECTION

➢ PROJECTION

➢ JOIN

➢ DIVISION

➢ RENAME
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. Example:
Syntax: A = { clerk, manager, salesman}
B = { president, clerk, manager}
A UNION B (or) A U B 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. Example:
Syntax: A = { clerk, manager, salesman}
B = { president, clerk, manager}
A INTERSECT B (or) A ∩ B A INTERSECT B = { clerk, manager}

3. DIFFERENCE (─): A and B are two relations. It displays elements in relation A not in relation B.
Syntax:
Example:
A MINUS B (OR) A ─ B
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:
Example:
A TIMES B (OR) A X B
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 (σ): Selection operation chooses the subset of tuples from the relation that satisfies the given
condition.

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 attribute1 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:

π(col1,col2…) Relation Name


Example:

π(sno, sname, total) MARKS

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

•Outer Join

•Left Outer Join

•Right Outer Join


SQL Joins are used to combine rows from two or more tables based on a related column between them. They help
in retrieving connected data stored across multiple tables.
1. SQL INNER JOIN

SELECT table1.column1,table1.column2,table2.column1,.... FROM


table1 INNER JOIN
table2 ON table1.matching_column = table2.matching_column;
SELECT StudentCourse.COURSE_ID, [Link], [Link] FROM Student
INNER JOIN StudentCourse
ON Student.ROLL_NO = StudentCourse.ROLL_NO;
[Link] LEFT JOIN

A LEFT JOIN returns all rows from the left table, along with matching rows from the right table. If there is no match,
NULL values are returned for columns from the right table. LEFT JOIN is also known as LEFT OUTER JOIN.
SELECT table1.column1,table1.column2,table2.column1,....
FROM table1
LEFT JOIN table2
ON table1.matching_column = table2.matching_column;
In this example, the LEFT JOIN retrieves all rows from the Student table and the matching rows from the
StudentCourse table based on the ROLL_NO column.

SELECT [Link],StudentCourse.COURSE_ID
FROM Student
LEFT JOIN StudentCourse
ON StudentCourse.ROLL_NO = Student.ROLL_NO;
3. SQL RIGHT JOIN

RIGHT JOIN returns all the rows of the table on the right side of the join and matching rows for the table on the left
side of the join. It is very similar to LEFT JOIN for the rows for which there is no matching row on the left side, the
result-set will contain null. RIGHT JOIN is also known as RIGHT OUTER JOIN.

SELECT table1.column1,table1.column2,table2.column1,....
FROM table1
RIGHT JOIN table2
ON table1.matching_column = table2.matching_column;
In this example, the RIGHT JOIN retrieves all rows from the StudentCourse table and the matching rows from the
Student table based on the ROLL_NO column.
Query:

SELECT [Link],StudentCourse.COURSE_ID
FROM Student
RIGHT JOIN StudentCourse
ON StudentCourse.ROLL_NO = Student.ROLL_NO;
4. SQL FULL JOIN

FULL JOIN creates the result-set by combining results of both LEFT JOIN and RIGHT JOIN. The result-set will
contain all the rows from both tables. For the rows for which there is no matching, the result-set will contain NULL
values.
SELECT table1.column1,table1.column2,table2.column1,....
FROM table1
FULL JOIN table2
ON table1.matching_column = table2.matching_column;

This example uses a FULL JOIN to return all rows from both tables. Matching records appear together, while non-
matching records still show up with NULL values for the missing fields.
SELECT [Link],StudentCourse.COURSE_ID
FROM Student
FULL JOIN StudentCourse
ON StudentCourse.ROLL_NO = Student.ROLL_NO;
5. SQL Natural Join
A Natural Join is a type of INNER JOIN that automatically joins two tables based on columns with the same name
and data type. It returns only the rows where the values in the common columns match.
•It joins tables using common columns with the same name.

•It returns only rows where values in those columns match.

•The common column appears only once in the result.


SELECT
Emp_name,
Dept_name
FROM Employee
NATURAL JOIN Department;
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)

ρ(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 & Disadvantages of Relational Algebra

You might also like