0% found this document useful (0 votes)
2 views

RDBMS_UNIT1_

Uploaded by

krishna17may2006
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

RDBMS_UNIT1_

Uploaded by

krishna17may2006
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Uni:1 , RDBMS

UNIT:1 Introduction of Relational model

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.

Rule 1: Information Rule

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.

Rule 2: Guaranteed Access Rule

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.

Rule 3: Systematic Treatment of Null Values

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.

Rule 4: Active/Dynamic Online Catalog based on the relational model

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.

Rule 5: Comprehensive Data Sub Language Rule

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.

Rule 6: View Updating Rule

All views table can be theoretically updated and must be practically updated by the database
systems.

Rule 7: High-Level Insert, Update and delete

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.

Rule 9: Logical Data Independence Rule

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.

Note: This rule is most difficult to achieve

Rule 10: Integrity Independence Rule

A database must be independent of the application that uses it.

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

Rule 11: Distribution Independence Rule

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.

Rule 12: Non-Subversion Rule

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

➢ Relational algebra is a procedural query language.


➢ It gives a step-by-step process to obtain the result of the query.
➢ It uses operators to perform queries.

YESHA NAHIYERA,
3
SSACCM,NAVSARI
Such notations are,

• Select (σ)
• Project (∏)
• Union ( )
• Intersection (∩)
• Rename (ρ)

Select Operator (σ):

➢ Select Operator is denoted by sigma (σ)

➢ it is used to find the tuples (or rows) in a relation (or table) which satisfy the given
condition.

Syntax:

σ Condition (Table name)

Example:

Table: CUSTOMER
---------------

Customer_Id Customer_Name Customer_City

----------- ------------- -------------


C10100 Steve Agra
C10111 Raghu Agra
C10115 Chaitanya Noida
C10117 Ajeet Delhi
C10118 Carl Delhi

Notation:

σ Customer_City="Agra" (CUSTOMER)
Output:

Customer_Id Customer_Name Customer_City


----------- ------------- -------------
C10100 Steve Agra
C10111 Raghu Agra

YESHA NAHIYERA,
4
SSACCM,NAVSARI
Project Operator (∏):

➢ Project operator is denoted by ∏ symbol

➢ It is used to select desired columns (or attributes) from a table (or relation).

➢ Project operator in relational algebra is similar to the Select statement in SQL.

Syntax:

∏ column_name1, column_name2, ...., column_nameN (table_name) Example

Example:

Table: CUSTOMER

Customer_Id Customer_Name Customer_City


----------- ------------- -------------
C10100 Steve Agra
C10111 Raghu Agra
C10115 Chaitanya Noida
C10117 Ajeet Delhi
C10118 Carl Delhi

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 ( ):

➢ Union operator is denoted by symbol.

➢ It is used to select all the rows (tuples) from two tables (relations).

➢ R and S must have the attribute of the same number.

➢ Duplicate tuples are eliminated automatically.

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

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)

YESHA NAHIYERA,
6
SSACCM,NAVSARI
➢ Intersection operator is denoted by ∩ symbol.

➢ It is used to select common rows (tuples) from two tables (relations).

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

Rename Operator (ρ):

➢ Rename operation can be used to rename a relation or an attribute of a relation.


➢ It is denoted by rho (ρ)
➢ Rename can Change name of the relation and attribute.

Syntax:
ρ(new_relation_name, old_relation_name)

Notation:
ρ(STUDENT1, STUDENT)

❖ Data Control Language

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

GRANT SELECT, UPDATE ON EMP TO BCA123;


b. Revoke: It is used to take back permissions from the user.
Example

1. REVOKE SELECT, UPDATE ON EMP FROM BCA123;

❖ Transaction Control Language

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

DELETE FROM CUSTOMERS


WHERE AGE = 25;

COMMIT;

YESHA NAHIYERA,
9
SSACCM,NAVSARI
Rollback: Rollback command is used to undo transactions that have not already been saved to the
database.

This command restores the database to last APPLIED state.

It is also used with SAVEPOINT command to jump to a save point in an ongoing transaction.

Syntax:

ROLLBACK; / ROLLBACK TO SAVEPOINT;

Example:

DELETE FROM CUSTOMERS


WHERE AGE = 25;

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

Insert into demo


Values
(2,’megh’,’bba’);

Rollback to A;

YESHA NAHIYERA,
10
SSACCM,NAVSARI

You might also like