You are on page 1of 26

Database Management Systems

Text Book
Fundamentals of Database Systems,
R. Elmasri & S.B. Navathe
Pearson education, 2011.

Reference Books
1. Database Management Systems,
Raghu Ramakrishnan & Johannes Gehrke
Tata McGraw Hill, 2010.
2. Database System Concepts, Abraham Silberschatz,
Henry F. Korth & S. Sudarshan, Tata McGraw Hill, 2011.
3. Database Systems: Design, Implementation, and
Management, Peter Rob & Carlos Coronel, Cengage
Learning, 2011.

1
Relational database
• A relational database is a collection of tables.
• A table has column header and row.
• Every column header has a semantic.

• A table is stored as a file.


• Row of a table = record of a file
• Column header of a table = field name of a record.

• A table is loosely called a relation.


• But there are differences between a table and a relation.

Column header is also called data element.

2
An example of a relational database

3
Primary key of a table

A primary key of a table consists of one or more column


headers that can uniquely identify rows of a table.

If a primary key consists of multiple column headers then it


is called a composite primary key.

Primary key cannot be null. Primary key must have value in


every row of a table.

A part of a primary key is not a primary key.

4
Candidate key of a table
A candidate key consists of one or more column headers
that can uniquely identify rows of a table.

If there is only one candidate key in a table then the


candidate key is designated as a primary key.

If there are multiple candidate keys then one of them is


designated as a primary key and others are called unique
keys or secondary keys.

5
Foreign key of table
• A foreign key consists of one or more column headers
with the same data type as that of a primary key of the
same table or of a different table.
• Data type of foreign key must be the same as that of the
primary key.
• Foreign key refers to primary key

Dno is a foreign key of EMPLOYEE table and it refers to


Dnumber of DEPARTMENT table.

Mgr_ssn is a foreign key of EMPLOYEE table and it refers to


Ssn of EMPLOYEE table

6
Foreign key
In a database, you may find a large number of
foreign keys.

The foreign key column and the primary key


column may have same name if they belong to
different table.

7
Constraints
constraint = restriction

primary key – constraint

unique key – constraint

foreign key – constraint


(Foreign key constraint is also called referential integrity
constraint)

Domain constraint
data type defines domain constraint.

8
What is a database?

A database is a collection of related data.

9
What is a database management system?
A database management system (DBMS) is a collection
of software programs that enable users to create and
maintain a database.

Commercial DBMS product


DB2 & Informix Dynamic Server (from IBM),
Oracle & Rdb (from Oracle),
Sybase DBMS (from Sybase) &
SQLServer and Access (from Microsoft)
Several open source systems, such as
MySQL, PostgreSQL
(ALL are RDBMS products)

10
What is a database system?
Database system = Database + DBMS software

11
What is a database schema?
The description of a database is called database
schema.

12
Company database schema
EMPLOYEE(Fname, Minit, Lname, Ssn, Bdate, Address,
Gender, Salary, Super_ssn, Dno)

DEPARTMENT(Dname, Dnumber, Mgr_ssn, Mgr_strat_date)

PROJECT(Pname, Pnumber, Plocation, Dnum)

DEPT_LOCATIONS(Dnumber, Dlocation)

WORKS_ON(Essn, Pno, Hours)

DEPENDENT(Essn, Dependent_name, Gender, Bdate,


Relationship)

13
Company database schema containing data type
EMPLOYEE(Fname:string, Minit:char, Lname:string, Ssn:string,
Bdate:date, Address:string, Gender:char, Salary:real,
Super_ssn:string, Dno:char)

DEPARTMENT(Dname:string, Dnumber:char, Mgr_ssn:string,


Mgr_start_date:date)

PROJECT(Pname:string, Pnumber:string, Plocation:string,


Dnum:char)
DEPT_LOCATIONS(Dnumber:char, Dlocation:string)

WORKS_ON(Essn:string, Pno:string, Hours:real)

DEPENDENT(Essn:string, Dependent_name:string, Gender:char,


Bdate:date, Relationship:string)

14
What is a schema diagram?

A displayed schema is a called a schema diagram.

Pictorial representation of schema is called


schema diagram

15
16
What is a schema construct?

Each object in a schema diagram is called a


schema construct.

e.g. EMPLOYEE, DEPARTMENT, PROJECT,


WORKS_ON

17
Schema diagram of an Airline database
18
Identify foreign keys in the above schema
Library database schema diagram

19
Identify foreign keys in the above schema
Schema of a student database in a university

Identify foreign keys in the above schema

Write down the create table statements for the above schema.

20
Schema of a car database

Identify foreign keys in the above schema

Write down the create table statements for the above schema.

21
Schema diagram of company database
22
What is a database state?

Data present in a database at a particular point of


time defines database state.

The database state is also called database


snapshot or database instance.

Database state is changed frequently.

23
Is it possible to change database schema?

Database schema can be changed but the change


is infrequent.

Database schema is also called intension of the


database,
Database state is called an extension of the
schema.

Database state is changed frequently.


Database schema is changed infrequently.
24
Meta data & DBMS catalog
Information about a database schema is called
meta data.

DBMS stores the descriptions of the schema


constructs and constraints—also called the meta-
data—in the DBMS catalog.

Meta-data means data about data.

Information about schema User data

25
We interact with database in our day-to-day life
through various activities
• Registering courses at the beginning of the semester
• Checking attendance status (almost everyday)
• Viewing results after term end examination
• Depositing / withdrawing money from bank
• Checking balance in your bank account
• Booking railway/airline ticket online
• Booking hotel room online
• Buying goods (books, apparel, footwear, mobile handset
and other things) online (from www.flipcart.com)
• Accessing www.youtube.com

26

You might also like