A.KAVITHA
ASSISTANT PROFESSOR
E.M.G YADAVA WOMEN’S COLLEGE,MADURAI
UNIT II
RDBMS:INTRODUCTION
TERMINOLOGY
RELATIONAL DATA STRUCTURE
RELATIONAL DATA INTEGRITY
RELATIONAL DATA MANIPULATION
CODD’S RULES
RDBMS:INTRODUCTION
RDBMS stands for Relational Database Management System. RDBMS is the basis for SQL, and
for all modern database systems like MS SQL Server, IBM DB2, Oracle, MySQL, and Microsoft
Access.
A Relational database management system (RDBMS) is a database management system
(DBMS) that is based on the relational model as introduced by E. F. Codd.
TERMINOLOGY
The data in an RDBMS is stored in database objects which are called as tables. This table is
basically a collection of related data entries and it consists of numerous columns and rows.
Every table is broken up into smaller entities called fields. The fields in the CUSTOMERS table
consist of ID, NAME, AGE, ADDRESS and SALARY.
A record is also called as a row of data is each individual entry that exists in a table. For
example, there are 7 records in the above CUSTOMERS table.
A column is a vertical entity in a table that contains all information associated with a specific field
in a table.
A NULL value in a table is a value in a field that appears to be blank, which means a field with a
NULL value is a field with no value.
Primary Key
Every table has one Primary key and cannot have null values.
Foreign Key
If you want to link two tables, use Foreign Key.
For example, Employee table has DEPT_ID that is a foreign key, which is linked to
Department table.
The Department table has primary key DEPT_ID.
Super Key
Super Key is an attribute (or a set of attributes) that uniquely identify a tuple i.e. an
entity in entity set. It is a superset of Candidate Key, since Candidate Keys are
selected from super key.
Composite Key
A primary key having two or more attributes is called composite key. It is a
combination of two or more columns.
RELATIONAL DATA STRUCTURE
In relational model, the data and relationships are represented by collection of inter-
related tables. Each table is a group of column and rows, where column represents
attribute of an entity and rows represents records.
Sample relationship Model: Student table with 3 columns and four records.
Stu_Id Stu_Name Stu_Age
111 Ashish 23
123 Saurav 22
169 Lester 24
234 Sam 26
Tables − In relational data model, relations are saved in the format of Tables. This
format stores the relation among entities. A table has rows and columns, where rows
represents records and columns represent the attributes.
Tuple − A single row of a table, which contains a single record for that relation is
called a tuple.
Relation instance − A finite set of tuples in the relational database system represents
relation instance. Relation instances do not have duplicate tuples.
Relation schema − A relation schema describes the relation name (table name),
attributes, and their names.
Relation key − Each row has one or more attributes, known as relation key, which
can identify the row in the relation (table) uniquely.
Attribute domain − Every attribute has some pre-defined value scope, known as
attribute domain.
Data integrity is enforced in both hierarchical and relational database models.
The following three integrity constraints are used in a relational database
structure to achieve data integrity:
Entity Integrity: This is concerned with the concept of primary keys. The rule
states that every table must have its own primary key and that each has to be
unique and not null.
Referential Integrity: This is the concept of foreign keys. The rule states that
the foreign key value can be in two states. The first state is that the foreign
key value would refer to a primary key value of another table, or it can be null.
Being null could simply mean that there are no relationships, or that the
relationship is unknown.
Domain Integrity: This states that all columns in a relational database are in a
defined domain.
RELATIONAL DATA INTEGRITY
RELATIONAL DATA MANIPULATION
A data manipulation language (DML) is a computer programming language used for adding
(inserting), deleting, and modifying (updating) data in a database A DML is often a sublanguage of a
broader database language such as SQL,with the DML comprising some of the operators in the
language.
DML commands are used to modify the database. It is responsible for all form of changes in the
database
INSERT
UPDATE
DELETE
INSERT: The INSERT statement is a SQL query. It is used to insert data into the row of a table.
Syntax:
Syntax:
INSERT INTO TABLE_NAME
(col1, col2, col3,.... col N)
VALUES (value1, value2, value3, .... valueN);
UPDATE: This command is used to update or modify the value of a column in the
table.
Syntax:
UPDATE table_name SET [column_name1= value1,...column_nameN = valueN]
[WHERE CONDITION]
DELETE: It is used to remove one or more row from a table.
Syntax:
DELETE FROM table_name [WHERE condition];
Codd's Rule for Relational DBMS
E.F Codd was a Computer Scientist who invented the Relational model for Database
management. Based on relational model, the Relational database was created. Codd
proposed 13 rules popularly known as Codd's 12 rules to test DBMS's concept
against his relational model.
Rule zero
This rule states that for a system to qualify as an RDBMS, it must be able to manage
database entirely through the relational capabilities.
Rule 1: Information rule
All information(including metadata) is to be represented as stored data in cells of
tables. The rows and columns have to be strictly unordered.
Rule 2: Guaranted Access
Each unique piece of data(atomic value) should be accesible by : Table Name +
Primary Key(Row) + Attribute(column).
Rule 3: Systematic treatment of NULL
Null has several meanings, it can mean missing data, not applicable or no value. It should be handled consistently.
Also, Primary key must not be null, ever. Expression on must give null.
Rule 4: Active Online Catalog
Database dictionary(catalog) is the structure description of the complete Database and it must be stored online.
The Catalog must be governed by same rules as rest of the database.
Rule 5: The comprehensive data sublanguage rule:
relational system may support several languages and various modes of terminal. However, there must be at least
one language whose statements are expressible, per some well-defined syntax, as character strings and that is
comprehensive in supporting all of the following items:
Data definition.
View definition.
Data manipulation (interactive and by program).
Integrity constraints.
Authorization.
Transaction boundaries (begin, commit and rollback).
Rule 6: The updating rule:All views that are theoretically updatable are also updatable by the system.
Rule 7: Relational Level Operation
There must be Insert, Delete, Update operations at each level of relations. Set operation like Union,
Intersection and minus should also be supported.
Rule 8: Physical Data Independence
The physical storage of data should not matter to the system. If say, some file supporting table is renamed or
moved from one disk to another, it should not effect the application.
Rule 9: Logical Data Independence
If there is change in the logical structure(table structures) of the database the user view of data should not
change. Say, if a table is split into two tables, a new view should give result as the join of the two tables.
Rule 10: Integrity Independence
The database should be able to enforce its own integrity rather than using other programs. Key and Check
constraints, trigger etc, should be stored in Data Dictionary.
Rule 11: Distribution Independence
A database should work properly regardless of its distribution across a network. Even if a database is
geographically distributed, with data stored in pieces, the end user should get an impression that it is stored at
the same place.
Rule 12: Nonsubversion Rule
If low level access is allowed to a system it should not be able to subvert or bypass integrity rules to change the
data.
Relational Database Management System part II

Relational Database Management System part II

  • 1.
  • 3.
    UNIT II RDBMS:INTRODUCTION TERMINOLOGY RELATIONAL DATASTRUCTURE RELATIONAL DATA INTEGRITY RELATIONAL DATA MANIPULATION CODD’S RULES
  • 4.
    RDBMS:INTRODUCTION RDBMS stands forRelational Database Management System. RDBMS is the basis for SQL, and for all modern database systems like MS SQL Server, IBM DB2, Oracle, MySQL, and Microsoft Access. A Relational database management system (RDBMS) is a database management system (DBMS) that is based on the relational model as introduced by E. F. Codd. TERMINOLOGY The data in an RDBMS is stored in database objects which are called as tables. This table is basically a collection of related data entries and it consists of numerous columns and rows. Every table is broken up into smaller entities called fields. The fields in the CUSTOMERS table consist of ID, NAME, AGE, ADDRESS and SALARY. A record is also called as a row of data is each individual entry that exists in a table. For example, there are 7 records in the above CUSTOMERS table. A column is a vertical entity in a table that contains all information associated with a specific field in a table. A NULL value in a table is a value in a field that appears to be blank, which means a field with a NULL value is a field with no value.
  • 5.
    Primary Key Every tablehas one Primary key and cannot have null values. Foreign Key If you want to link two tables, use Foreign Key. For example, Employee table has DEPT_ID that is a foreign key, which is linked to Department table. The Department table has primary key DEPT_ID. Super Key Super Key is an attribute (or a set of attributes) that uniquely identify a tuple i.e. an entity in entity set. It is a superset of Candidate Key, since Candidate Keys are selected from super key. Composite Key A primary key having two or more attributes is called composite key. It is a combination of two or more columns.
  • 6.
    RELATIONAL DATA STRUCTURE Inrelational model, the data and relationships are represented by collection of inter- related tables. Each table is a group of column and rows, where column represents attribute of an entity and rows represents records. Sample relationship Model: Student table with 3 columns and four records. Stu_Id Stu_Name Stu_Age 111 Ashish 23 123 Saurav 22 169 Lester 24 234 Sam 26
  • 7.
    Tables − Inrelational data model, relations are saved in the format of Tables. This format stores the relation among entities. A table has rows and columns, where rows represents records and columns represent the attributes. Tuple − A single row of a table, which contains a single record for that relation is called a tuple. Relation instance − A finite set of tuples in the relational database system represents relation instance. Relation instances do not have duplicate tuples. Relation schema − A relation schema describes the relation name (table name), attributes, and their names. Relation key − Each row has one or more attributes, known as relation key, which can identify the row in the relation (table) uniquely. Attribute domain − Every attribute has some pre-defined value scope, known as attribute domain.
  • 8.
    Data integrity isenforced in both hierarchical and relational database models. The following three integrity constraints are used in a relational database structure to achieve data integrity: Entity Integrity: This is concerned with the concept of primary keys. The rule states that every table must have its own primary key and that each has to be unique and not null. Referential Integrity: This is the concept of foreign keys. The rule states that the foreign key value can be in two states. The first state is that the foreign key value would refer to a primary key value of another table, or it can be null. Being null could simply mean that there are no relationships, or that the relationship is unknown. Domain Integrity: This states that all columns in a relational database are in a defined domain. RELATIONAL DATA INTEGRITY
  • 9.
    RELATIONAL DATA MANIPULATION Adata manipulation language (DML) is a computer programming language used for adding (inserting), deleting, and modifying (updating) data in a database A DML is often a sublanguage of a broader database language such as SQL,with the DML comprising some of the operators in the language. DML commands are used to modify the database. It is responsible for all form of changes in the database INSERT UPDATE DELETE INSERT: The INSERT statement is a SQL query. It is used to insert data into the row of a table. Syntax: Syntax: INSERT INTO TABLE_NAME (col1, col2, col3,.... col N) VALUES (value1, value2, value3, .... valueN);
  • 10.
    UPDATE: This commandis used to update or modify the value of a column in the table. Syntax: UPDATE table_name SET [column_name1= value1,...column_nameN = valueN] [WHERE CONDITION] DELETE: It is used to remove one or more row from a table. Syntax: DELETE FROM table_name [WHERE condition];
  • 11.
    Codd's Rule forRelational DBMS E.F Codd was a Computer Scientist who invented the Relational model for Database management. Based on relational model, the Relational database was created. Codd proposed 13 rules popularly known as Codd's 12 rules to test DBMS's concept against his relational model. Rule zero This rule states that for a system to qualify as an RDBMS, it must be able to manage database entirely through the relational capabilities. Rule 1: Information rule All information(including metadata) is to be represented as stored data in cells of tables. The rows and columns have to be strictly unordered. Rule 2: Guaranted Access Each unique piece of data(atomic value) should be accesible by : Table Name + Primary Key(Row) + Attribute(column).
  • 12.
    Rule 3: Systematictreatment of NULL Null has several meanings, it can mean missing data, not applicable or no value. It should be handled consistently. Also, Primary key must not be null, ever. Expression on must give null. Rule 4: Active Online Catalog Database dictionary(catalog) is the structure description of the complete Database and it must be stored online. The Catalog must be governed by same rules as rest of the database. Rule 5: The comprehensive data sublanguage rule: relational system may support several languages and various modes of terminal. However, there must be at least one language whose statements are expressible, per some well-defined syntax, as character strings and that is comprehensive in supporting all of the following items: Data definition. View definition. Data manipulation (interactive and by program). Integrity constraints. Authorization. Transaction boundaries (begin, commit and rollback). Rule 6: The updating rule:All views that are theoretically updatable are also updatable by the system.
  • 13.
    Rule 7: RelationalLevel Operation There must be Insert, Delete, Update operations at each level of relations. Set operation like Union, Intersection and minus should also be supported. Rule 8: Physical Data Independence The physical storage of data should not matter to the system. If say, some file supporting table is renamed or moved from one disk to another, it should not effect the application. Rule 9: Logical Data Independence If there is change in the logical structure(table structures) of the database the user view of data should not change. Say, if a table is split into two tables, a new view should give result as the join of the two tables. Rule 10: Integrity Independence The database should be able to enforce its own integrity rather than using other programs. Key and Check constraints, trigger etc, should be stored in Data Dictionary. Rule 11: Distribution Independence A database should work properly regardless of its distribution across a network. Even if a database is geographically distributed, with data stored in pieces, the end user should get an impression that it is stored at the same place. Rule 12: Nonsubversion Rule If low level access is allowed to a system it should not be able to subvert or bypass integrity rules to change the data.