RDBMS_UNIT1_
RDBMS_UNIT1_
12 Codd's Rules
➢ Every database has tables, and constraints cannot be referred to as a rational database
system.
➢ There are some rules that define a database to be the correct RDBMS.
➢ These rules were developed by Dr. Edgar F. Codd (E.F. Codd) in 1985, who has vast
research knowledge on the Relational Model of database Systems.
➢ Codd presents his 13 rules for a database to test the concept of DBMS against his
relational model, and if a database follows the rule, it is called a true relational database
(RDBMS).
➢ These 13 rules are popular in RDBMS, known as Codd's 12 rules.
Rule 0: The Foundation Rule
The database must be in relational form. So that the system can handle the database through its
relational capabilities.
A database contains various information, and this information must be stored in each cell of a
table format in the form of rows and columns.
Every single or precise data (atomic value) may be accessed logically from a relational database
using the combination of primary key value, table name, and column name.
This rule defines the systematic treatment of Null values in database records. The null value
has various meanings in the database, like missing the data, no value in a cell, inappropriate
information, unknown data and the primary key should not be null.
It represents the entire logical structure of the descriptive database that must be stored online
and is known as a database dictionary. It authorizes users to access the database and implement
a similar query language to access the database.
A database can only be accessed using a one language having linear syntax that supports data
definition, data manipulation, and transaction management operations.
This language can be used directly or by means of some application.
All views table can be theoretically updated and must be practically updated by the database
systems.
A database system should follow high-level complex relational operations such as insert,
update, and delete in each level or a single row.
YESHA NAHIYERA,
2
SSACCM,NAVSARI
Rule 8: Physical Data Independence Rule
The data stored in a database must be independent of the applications that access the database.
Any change in the physical structure of a database must not have any impact on how the data
is being accessed by external applications.
It is similar to physical data independence. It means, if any changes occurred to the logical level
(table structures), it should not affect the user's view (application).
For example, suppose a table either split into two tables, or two table joins to create a single
table, these changes should not be impacted on the user view application.
All its integrity constraints can be independently modified or added without the need of any
change in the view of application.
This rule makes a database independent of the front-end application and its interface
The end-user must not be able to see that the data is distributed over various locations. Users
should always get the impression that the data is located at one site only. This rule has been
regarded as the foundation of distributed database systems.
If a system has an interface that provides access to low-level records, then the interface must
not be able to subvert the system and bypass security and integrity constraints.
❖ Relational Algebra
YESHA NAHIYERA,
3
SSACCM,NAVSARI
Such notations are,
• Select (σ)
• Project (∏)
• Union ( )
• Intersection (∩)
• Rename (ρ)
➢ it is used to find the tuples (or rows) in a relation (or table) which satisfy the given
condition.
Syntax:
Example:
Table: CUSTOMER
---------------
Notation:
σ Customer_City="Agra" (CUSTOMER)
Output:
YESHA NAHIYERA,
4
SSACCM,NAVSARI
Project Operator (∏):
➢ It is used to select desired columns (or attributes) from a table (or relation).
Syntax:
Example:
Table: CUSTOMER
Notation:
∏ Customer_Name, Customer_City (CUSTOMER)
Output:
Customer_Name Customer_City
------------- -------------
Steve Agra
Raghu Agra
Chaitanya Noida
Ajeet Delhi
Carl Delhi
YESHA NAHIYERA,
5
SSACCM,NAVSARI
Union Operator ( ):
➢ It is used to select all the rows (tuples) from two tables (relations).
Syntax:
(Tablename1) ∪ (Tablename2)
Example:
Table 1: COURSE
Course_Id Student_Name Student_Id
--------- ------------ ----------
C101 Aditya S901
C104 Aditya S901
C106 Steve S911
C109 Paul S921
C115 Lucy S931
Table 2: STUDENT
Notation:
∏Student_Name(COURSE) ∏Student_name(STUDENT)
YESHA NAHIYERA,
6
SSACCM,NAVSARI
➢ Intersection operator is denoted by ∩ symbol.
➢ Suppose there are two tuples R and S. The set intersection operation contains all tuples
that are in both R & S.
Syntax:
Tablename1 ∩ Tablename2
Example:
Table 1: COURSE
Course_Id Student_Name Student_Id
--------- ------------ ----------
C101 Aditya S901
C104 Aditya S901
C106 Steve S911
C109 Paul S921
C115 Lucy S931
YESHA NAHIYERA,
7
SSACCM,NAVSARI
Table 2: STUDENT
Student_Id Student_Name Student_Age
------------ ---------- -----------
S901 Aditya 19
S911 Steve 18
S921 Paul 19
S931 Lucy 17
S941 Carl 16
S951 Rick 18
Notation:
∏Student_Name(COURSE) ∩ ∏Student_name(STUDENT)
Output:
Syntax:
ρ(new_relation_name, old_relation_name)
Notation:
ρ(STUDENT1, STUDENT)
➢ DCL commands are used to grant and take back authority from any database user.
➢ Here are some commands that come under DCL:
o Grant
o Revoke
YESHA NAHIYERA,
8
SSACCM,NAVSARI
a. Grant: It is used to give user access privileges to a database.
Example:
➢ TCL commands can only use with DML commands like INSERT, DELETE and UPDATE
only.
➢ These operations are automatically committed in the database that's why they cannot be used while
creating tables or dropping them.
➢
➢ Here are some commands that come under TCL:
o COMMIT
o ROLLBACK
o SAVEPOINT
Commit: Commit command is used to save all the transactions to the database.
Syntax:
COMMIT;
Example:
COMMIT;
YESHA NAHIYERA,
9
SSACCM,NAVSARI
Rollback: Rollback command is used to undo transactions that have not already been saved to the
database.
It is also used with SAVEPOINT command to jump to a save point in an ongoing transaction.
Syntax:
Example:
ROLLBACK;
SAVEPOINT: It is used to roll the transaction back to a certain point without rolling back the
entire transaction.
Syntax:
SAVEPOINT SAVEPOINT_NAME;
E.G:
Insert into demo Values
(1,’moksh’,’bca’);
Savepoint A; Jumps the transaction with reference of
‘A’ savepoint
Rollback to A;
YESHA NAHIYERA,
10
SSACCM,NAVSARI