Introduction To RDBMS Day - 1
Introduction To RDBMS Day - 1
Introduction To RDBMS Day - 1
Day - 1
What is Data?
Data (plural of the word Datum) - Data is a factual
information used as a basis for reasoning, discussion, or
calculation
Data may be numerical data which may be integers or
floating point numbers, and non-numerical data such as
characters, date and etc. Data by itself normally doesnt
have a meaning associated with it.
e.g:Krishnan
01-Jan-71
15-Jun-05
50000
Information
Related data is often called as information. Information will
always have a meaning and context attached to the data
element. Let us consider the same example that we gave
for data. When we add meaning and context to the data it
becomes information:
Database
A logically coherent collection of related data
(information) with inherent meaning, built for a certain
application, and representing a subset of the "real-world".
For e.g. a customer database in your bank, details of the
insurance policies that we hold etc.
Evolution of Databases
Hierarchical Model
Again consider the database representing a customeraccount relationship in a banking system. There are two
record types, customer and account.
type customer = record
customer name: string;
customer street: string;
customer city: string;
end
end
Hierarchical Model
Network Model
consider a database representing a customer-account
relationship in a banking system. There are two record
types, customer and account.
type customer = record
customer name: string;
customer street: string;
customer city: string;
end
end
Network Model
Account
emp_no
name
street
city
emp_no
ac_no
balance
E1
Hayes
Main
harrison
E1
A-102
400
E2
Jhonson
Alma
Palo alto
E2
A-101
500
E3
Turner
Putnam
stamford
E2
A-201
900
E3
A-304
300
Relational Model
Relationship is established with the help of keys
emp_no
name
street
city
E1
Hayes
Main
harrison
E2
Jhonson
Alma
Palo alto
E3
Turner
Putnam
stamford
emp_no
ac_no
balance
E1
A-102
400
E2
A-101
500
E2
A-201
900
E3
A-304
300
Purpose of a DBMS
DBMS developed to handle the following difficulties:
Functionality of a DBMS
Specifying the database structure
data definition language
Integrity enforcement
integrity constraints
Concurrent control
multiple user environment
Crash recovery
Security and authorization
DBMS Approach
Data independence
capability of changing a database scheme without having
to change the scheme at the next higher level
two level of data independence
Data Abstraction
Physical Level describes how data are actually stored
Logical Level describes what data are stored
View Level
describes only a part of the database
useful for a particular user
View 1
View 2
View n
Logical level
Physical level
Database Languages
data definition language (DDL) :
specify the conceptual database scheme
data manipulation language (DML): query language
used to retrieve and update information in a database
host language:
a conventional high level language used to write
application programs
DBMS Structure
Relations
Relations
Relations
Functional dependency
NORMALIZATION
Normalization
A company obtains parts from a number of suppliers. Each supplier is
located in one city. A city can have more than one supplier located there
and each city has a status code associated with it. Each supplier may
provide many parts. The company creates a simple relational table to
store this information that can be expressed in relational notation as:
FIRST (s#, status, city, p#, qty)
S#
Status
City
P#
qty
S1
20
London
p1,p2,p3
100,200,50
S2
10
Paris
p1,p2
200,100
S3
10
Paris
p1
200
S4
20
London
p4,p5
100,50
1 NF Anomalies
contains redundant data. For example, information about the
supplier's location and the location's status have to be
repeated for every part supplied.
Redundancy causes what are called update anomalies.
2 NF
2 NF
The process for transforming a 1NF table to 2NF is:
1. Identify any determinants other than the composite key, and the
columns they determine.
2. Create and name a new table for each determinant and the
unique columns it determines.
3. Move the determined columns from the original table to the new
table. The determinate becomes the primary key of the new
table.
4. Delete the columns you just moved from the original table except
for the determinate which will serve as a foreign key.
5. The original table may be renamed to maintain semantic
meaning.
2 NF
To transform FIRST into 2NF we move the columns s#,
status, and city to a new table called SECOND. The column
s# becomes the primary key of this new table
2 NF Anomalies
Tables in 2NF but not in 3NF still contain modification
anomalies. In the example of SECOND, they are:
3 NF
3 NF
The process of transforming a table into 3NF is:
1. Identify any determinants, other the primary key, and the columns
they determine.
2. Create and name a new table for each determinant and the
unique columns it determines.
3. Move the determined columns from the original table to the new
table. The determinate becomes the primary key of the new table.
4. Delete the columns you just moved from the original table except
for the determinate which will serve as a foreign key.
5. The original table may be renamed to maintain semantic
meaning.
3 NF
create a new table called CITY_STATUS and move the columns city
and status into it. Status is deleted from the original table, city is left
behind to serve as a foreign key to CITY_STATUS, and the original
table is renamed to SUPPLIER_CITY to reflect its semantic meaning
3 NF
The results of putting the original table into 3NF has
created three tables. These can be represented in
"psuedo-SQL" as:
PARTS (#s, p#, qty)
Primary Key (s#,#p)
Foreign Key (s#) references SUPPLIER_CITY.s#
SUPPLIER_CITY(s#, city)
Primary Key (s#)
Foreign Key (city) references CITY_STATUS.city
CITY_STATUS (city, status)
Primary Key (city)
INSERT. Facts about the status of a city, Rome has a status of 50,
can be added even though there is not supplier in that city.
Likewise, facts about new suppliers can be added even though
they have not yet supplied parts.
www.igate.com