You are on page 1of 30

Chapter 10

Relational Databases

Relational Database
A database management system (DBMS)
that stores data in the form of related tables
is called a relational Database management
system
The goal of a relational database
management system (RDBMS) is to make
data easy to store and retrieve

Relational Database
Relational Database: A method of structuring data as
collections of tables that are logically associated to
each other by shared attributes. A relationship is
established using a common field.
Lines

Related External Database Table


Common Field
Line Attribute Table

Relational Database
Using the ability to relate tabular data from
multiple sources (different tables) the database
user is able to ask more complicated questions
(queries) of the data
Depending upon the relationship of the data and
the type of question, records are combined from
one table to another.
The ability to establish a relationship between
tables is dependent upon a common (or Key)
field found in both of the tables to be joined or
related.

Primary key and Foreign key


Each row of data in a table is uniquely identified by a
primary key (PK) constraint.
You can logically relate information from multiple
tables using foreign key (FK) constraint.
Table Name: CUSTOMER
ID
201
202
203
204

NAME
Unisports
Simms Atheletics
Delhi Sports
Womansport

Primary Key

SALES_
PHONE
REP_ID
55-2066101
12
81-20101
14
91-10351
14
1-206-104-0103
11

Foreign Key

Table Name: EMP


ID
10
11
12
14

LAST_NAME
Havel
Magee
Giljum
Nguyen

Primary Key

FIRST_NAME
Marta
Colin
Henry
Mai

Data Definition
Data definition is related to defining and
organizing data within a structure (tables)
Each table must obey certain rules called Data
Normalization
Normalization refers to the optimization of
tables to remove any redundancy
Most database are normalized only up to the
third Normal Form

Normalization

First Normal Form (1NF)


Second Normal Form (2NF)
Third Normal Form (3NF)
Boyce- Codd Normal Form (BCNF)
Fourth Normal Form (4NF)
Fifth Normal Form (5NF)

Normalization
Normalization is a multi-step process
beginning with an un normalized relation
First Normal Form:
Every Table must have a Primary Key
There can be more than one Primary Key in a table

Second Normal Form:


only one value must be stored in each cell
So if there is a column for phone numbers, it
cannot hold a home phone number and a business
phone number

Un normalized relation
ENO

Name

City

Madurai

Ragu

phone
Home
11-12111

Business Fax
123-222- 312222
223458

11
22

Abdul

Trichy

123458-654- 125235-458 879


879458

33

Siraj

Chennai

312111-

312-222- 3129976
333-

First Normal Form


ENO#

Name

City

Madurai

Ragu

phone
Home
11-12111

Business Fax
123-222- 312222
223458

11
22

Abdul

Trichy

123458-654- 125235-458 879


879458

33

Siraj

Chennai

312111-

312-222- 3129976
333-

Second Normal Form


ENO#

Name

City

Home
phone

11-12111

Business
phone

Fax phone

123-222- 312-22222
3458

Madurai

Ragu
11
22

Abdul

Trichy

123458-654- 125235-458 879


879-458

33

Siraj

Chennai

312-

312-222- 312-

Normalization
Third Normal Form:
all the Non primary field in the table should be
a FULLY dependent on the primary key alone

Un normalized relation
C#

Name

Company City

11

Ragu

IBM

Madurai

22

Abdul

TCS

Trichy

33

Siraj

ORACLE Chennai

Third Normal Form


C#
11
22
33

Name
Ragu
Abdul
Siraj

CID
1
2
3

CID#
1
2
3

Name
IBM
TCS
ORACLE

City
Madurai
Trichy
Chennai

Data Input Screens


Data can be entered directly into database tables or
input FORMS can also be used to enter data
Data input screens are similar to paper forms
Three types of Information can be placed on an input
screen
Simple text
Input Blanks
Data retrieved from the database

Most database systems automatically enter certain


types of data, such as the current date, order number
etc.
If necessary users can change the automatically
generated value or date

Reports
A report from a database is a formatted output from a
query or search of the database
The report can be prepared to contain certain fields,
sorted in any order and laid out in a readable manner
Reports can also include summaries of columns
A report writer defines the placement and format of
columns, headings, footer information, column titles,
and pagination in database reports
Such reports can be generated automatically with the
help of application generators

Data Dictionary
A relational database system must maintain data
about the tables and all other objects in the database
This information is otherwise called as Meta data or
System Catalog
The data dictionary must store names of the relations
and the attributes of each relation
Data dictionaries are used by the database
administrator to query the status of a firms data
The administrator can make changes to the definitions
of selected data to incorporate new organizational
requirements

SQL
The database interrogation capability of a
database management system allows end users
with no programming language feature lets
users obtain immediate responses to ad hoc
data requests
The Structured Query language is a popular
query language includes both the data
definition and data manipulation operations
By combining keywords, users can create
queries that extract just the information they
are looking for

Data Retrieval (Queries) in SQL


Queries search the database, fetch info, and
display it. This is done using the keyword
SELECT , FROM & WHERE
SELECT : Lists the data items to be retrieved
FROM : Lists the tables or fields from which
the data will be retrieved
WHERE : Specifies the conditions and
parameters which will limit the search

SQL
Publishers
pub_id

pub_name

address

state

0736

New Age Books

1 1st Street

MA

0987

Binnet & Hardley

2 2nd Street

DC

1120

Algodata Infosys

3 3rd Street

CA

Data Retrieval (Queries)

SELECT * FROM publishers


pub_id

pub_name

address

state

0736

New Age Books

1 1st Street

MA

0987

Binnet & Hardley

2 2nd Street

DC

1120

Algodata Infosys

3 3rd Street

CA

The

Operator asks for every column in

Data Retrieval (Queries)


Queries can be more specific with a few
more lines
SELECT *
from publishers
where state = CA
pub_id

pub_name

address

state

0736

New Age Books

1 1st Street

MA

0987

Binnet & Hardley

2 2nd Street

DC

1120

Algodata Infosys

3 3rd Street

CA

Only publishers in CA are displayed

Distributed Databases
Location C

computer

computer
Location A

Location B

computer

Distributed Database
Many organizations replicate and distribute copies or
parts of databases to network servers at various sites
These distributed databases reside on network servers
on the World Wide Web, on corporate intranets or
extranets, or on other company networks
In a distributed system, there is a difference between
local and global transactions.
A local transaction accesses data only at the site
where the transaction was initiated
A global transaction however, either accesses data at a
site different from the one at which the transaction
was initiated or accesses data from different sites

Distributed Database - Advantages


A distributed database has many advantages:
Data can be shared
If one site fails the remaining site can continue to
operate

Data Warehousing
A data warehouse is a database which stores
large amounts of transactional data
Such a warehouse helps companies take
business and support decisions

Data Mining
Data Mining refers to analyzing the data from different
sources and perspectives and summarizing it into useful
information
The aim is to look for patterns in the data which can be used to
formulate a business strategy or to look for unusual behavior
Data mining applies statistical technique to find patterns in
large amounts of data
It processes data in a data warehouse to identify key factors
and trends and historical patterns of business activity
Managers can use this information to make strategic changes
in business operations to gain a competitive advantage in the
market

What is OODB?
A persistent and sharable collection of objects
defined by OO data model
OODB = OO + DB
Object Oriented:
complex objects, object identity, encapsulation,
inheritance, Polymorphism
Database:
Relationship, Consistency, recovery and an ad hoc
query facility
09/11/16

Why OODB?
Some applications not suited for RDB
Model real world more closely
Manage complex data relationships very well
CAD/CAM, multimedia, Graphical Map file, systems
modeling, etc.

Unified data model


Similar representation in memory and on disk
Less application code and more maintainable

Better performance
Store and retrieve objects as a whole
09/11/16

Thank you

You might also like