3. 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.
4. 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 selectedfrom super key.
Composite Key
A primary key having two or more attributes is calledcomposite key. It is a
combination of two or more columns.
5. RELATIONAL DATA STRUCTURE
In relational model, the data and relationships are represented by collection
of inter-relatedtables. Each table is a group of columnand 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
6. 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 singlerecord for that relation
is calleda 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 schemadescribes 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.
7. Data integrityis enforced in both hierarchical and relational database
models. The following three integrityconstraints 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 wouldrefer 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
8. 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);
9. 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 removeone or more row from a table.
Syntax:
DELETE FROM table_name [WHERE condition];
10. Codd's Rule for Relational DBMS
E.F Codd was a Computer Scientist who inventedthe 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. Codd's rule actualy
define what quality a DBMS requires in order to become a Relational
Database Management System(RDBMS).
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 strictlyunordered.
Rule 2: Guaranted Access
Each unique piece of data(atomic value)shouldbe accesible by : Table
Name + Primary Key(Row) + Attribute(column).
11. Rule 3: Systematictreatment of NULL
Null has severalmeanings, 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 givenull.
Rule 4: Active Online Catalog
Database dictionary(catalog) is the structuredescription of the complete Database and it must be
stored online. The Catalog must be governed by same rules as rest of the database. The same query
languageshould be used on catalog as used to query database.
Rule 5: The comprehensivedata sublanguagerule:
relational system may support severallanguagesand variousmodes of terminal use (for example, the
fill-in-the-blanks mode). However,theremust be at least one languagewhose statementsare
expressible, per some well-defined syntax,as character strings and that is comprehensivein supporting
all of the following items:Data definition.
View definition.
Data manipulation (interactiveand by program).
Integrityconstraints.
Authorization.
Transaction boundaries (begin, commit and rollback).
Rule 6: The view updating rule:All viewsthat are theoretically updatableare also updatable by the
system.
12. 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 changein the logical structure(tablestructures) of the database the user view of data
should not change.Say, if a table is split into two tables, a new view should giveresult as the join of
the two tables.
Rule 10: Integrity Independence
The databaseshould 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: DistributionIndependence
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 subvertor bypass integrity rules to
changethe data.