Database Management System
Database Management System
DBMS
1
Data and Information
SN Name Height
1 Rubina 5.4
2 Rabin 5.6
3 Raoul 5.8
3
• A collection of information
is stored in computer as a file.
Database Request
• Adding new file to the DB
• Inserting data into the DB file
• Retrieving/Viewing data from DB
• Updating data in DB database file
• Deleting data from the DB file
• Removing files from the DB
6
Advantages of DBMS
1. Data Integrity
2. Data security
3. Data Redundancy
4. Data Independence
5. Backup and Recovery
6. Multiple Access
7. Process Complex query
8. Provides Interface: Form, Report
7
Database Administrator (DBA)
Who?
• The most responsible person with
sound knowledge of DBMS and IT.
• Administrator of the system.
• Has the maximum amount of privileges.
• Keep the database server up-to-date
secure
• Provides information to users on
demand.
8
Qualities?
• Sound knowledge of database:
Database Design, SQL (Structured
Query Language) and database
report.
• Strong knowledge about computer
system, OS, networking,
• Knowledge of modern database
packages: MS-Access, MS SQL-
Server, My SQL, Sybase Oracle etc.
9
Role ?
• Responsible for database design
i.e. designing all tables, fields,
Forms, Report, relationship and
users’ privileges.
• Provides different interface for
data retrieving and entering.
• Creates user manuals, give
training, describing the facilities of
by the system
10
• Maintains database security,
backup strategy, integrity
constraints and documentation of
data dictionary.
• Supervises the addition,
modification and deletion data
from the database.
11
Database Model
• An approach to manage data in
database is called database model.
• Defines organizing principle of
database that gives the mechanism
for data access and store.
• most common database models
• Hierarchical Model
• Network Model
• Relational Model
• ER Model 12
Flat File system/File Processing
• Traditional way of storing data
electronically (before DBMS)
• Stores data in a single stream of bytes
(In One Binary File)
• Has number. of limitations. It does not
support data integrity, Security,
Relationship, etc.
• Difficult for complex request (query) to
the database. 13
Hierarchical Model
• The oldest type database models.
• Data is represented in the form of records.
• Each record has multiple fields/attributes.
• All record is arranged in database as tree
like structure.
• The relationship between the records is
called parent child relationship in which
any child record relates to only a single
parent type record.
14
Records
(Principal)
Exam
records
19
Customer_detail
fname Lname Street Acc_no
Abee Gurung Ratopool A001
Rita Shrestha Lagankhel A002
Ani Lama Jawalakhel A003
Account_detail
Acc_no Balance
A001 54000
A002 38005
A003 97005
Customer_detail
Account_detail
fname
Acc_no
Lname
balance
Street
20
Acc_no
Relationship
(Functional Cardinality)
• Relationship is the link between two more
tables.
• It shows the dependency between the tables
for building queries and make database
easy access.
• There are three types of relationship:
• One-to-one: Each record in table A must
have only one matching record in the other
table B and each record in table B must have
one matching record in table A.
21
College has Principal
Colleges Principal
GLOBAL MR ABC
UNIVERSAL MR XYZ
CAMPION Ms PQR
22
Department work Faculty
s
Department Faculty
COMPUTER MR HIM Sir
ECO MR Devendra
Sir
English MR Kumar Sir
MR Pradeep Sir
25
• Entity: It is the thing or object in the real world that
cab be distinguishable from the others.
Example: student, employee, bank_account etc.
• A collection of same entities is called entity set.
• It is expressed by rectangle.
• Attributes: An entity is described by a set of
properties called attributes.
For example s_id, roll, f_name, l_name, section,
etc are the attributes of an entity student.
• It is expressed by oval shape.
• Relationship: It is an association or dependency
between two entities.
• A collection of same relationships is called
relationship set.
• There are three types of relationship: one-to-one,
one-to-many and many-to-many.
• It is expressed by diamond shape.
26
Rectangle Entity or entity set
Ellipse
Attributes
R Relationship between entity sets
Links between the entity sets
roll f_na
co m
sid
me eco
sid
1 1
Student_detail R Exam_detail
l_na c al
me se acc tot
math
phon
e
27
Structured Query Language
• It is an international standard database query
language.
• It is adapted by many computer and
software manufacturers such as IBM,
Microsoft, Oracle, Sybase etc.
• It was developed in IBM's laboratory in 1970s.
• It was originally called sequel, after that
its name was changed into SQL.
• SQL is not a complete programming
languages.
• It is only used for communicating with BD.
• It defines both DDL and DML.
28
Data Definition Language
• It is used in order to define or specify the
logical structure of database. A few DDL
commands are:
– Create table
– Add/modify fields
– Delete table
29
Data Manipulation Language
• It is used in order to manipulate or access
data in database. A few DML commands
are
– Insert data value
– Select or view records
– Update records
– Delete records
30
Domain and tuple
31
Data Dictionary
• It is a file that contains meta-data i.e. data
about data.
• It is also called information system catalogue.
• It keeps all the information about the DB
system such as location, size of the database,
tables, records, fields, user information,
privileges, backup system, and recovery
system etc.
• It also defines the data types for each fields
etc.
• A good data dictionary always ensures the
consistency in data base.
32
Table, Schema and Instance
• A table contains a logical grouping inter related
data where the data is arranged in equal number of
rows and columns.
• Each column defines the fields or attributes of a
table.
• Each row in a table defines a record or tuple.
• A schema is the structure of a table i.e. it defines
attributes of an entity and domain of the attributes.
• Instance is interrelates data values in a record
• Schema for a table: a book
Book (bId, bName, price, no_copy, bAuthor)
• Instance for the table: book
A001 A Book On C 545 10 Paul & Kelly
33
Key
• Candidate Key: A Candidate key is the minimum
number of field or fields in a table that uniquely
determines a record in a table.
• Primary Key: A unique key can be designated as
primary key if it has a unique identification for each
record of a table.
• Any candidate key can be considered as the primary
key.
BOOK (bId, bName, price, no_copy, bAuthor)
Foreign Key: A field in the related table that the
primary key refers to is called foreign key.
• STUDENT( s_id, f_name, L_name, grade, sec, roll)
• EXAM( s_id, sub1, sub2, sub3, sub4, sub5, total)
34
Functional Dependency
• If a value of any field or attribute uniquely
determines the value for the other fields or
attributes, then the attributes are functionally
depends on the common field.
• In table: student, sid is the primary key which
uniquely determines all the data values for the
other attributes. So fname, lname, city, street,
mobile fields are functionally dependent on sid.
Student_table
sid Fname Lname City Street mobile
35
Normalization
• It is a database design process in which
complex database table is broken down
into simple separate tables.
• It minimizes and controls the duplication
of data in a database and also provides a
rapid search for data from the database.
• It reduces the complexity of database.
• It is a complex process with many rules
in many layers.
36
• There are five levels of normalization
process as shown in fig 1.
1NF
2NF
3NF
4NF
5NF
38
Let us consider the following example:
LIBRARY( member_id,
member_name,
book_code,
book_name,
issue_date,
return_date)
39
1NF ( First Normal Form)
• Definition: A table is in 1NF if, there are
no duplicate rows or columns in the table
and each data value in a field must be
atomic (single value) and same type.
• In above example member_name field is
not atomic, so it is divided into
member_fname & member_lname.
LIBRARY (member_id, member_fname,
member_lname, book_code, book_name,
issue_date, issue_return)
40
2NF (Second Normal Form)
41
LIBRARY (member_id, member_fname, member_fname, book_code,
book_name, issue_date, issue_return)
member_id member_fname
member_lname
book_code
book_name
issue_date return_date
43
Types of database
44
Centralized database system
• The database is stored in one main computer, called
database server and many terminals are connected to
the server with the help of network media.
• All data processing jobs are carried out in the server.
• Terminals have no ability to process or store data, its
just like interface to access database in server.
• It is simple types of database processing system with
low operating cost, low installation cost and limited
facilities.
• Data traffic might high in centralized database server.
• It is based on client-server architecture.
45
Terminal 1
Network Server
Terminal 2
DB
Terminal 3
46
Distributed database system
• The database is stored and processed in different
servers at different sites.
• Network communication media links the servers.
• The network might be LAN (Local Area Network) or
WAN (Wide Area Network).
• This system is based on distributed client-server
architecture where database is maintaining in
different servers with the help of different clients
associates with the servers respectively.
• Each server has equal privileges to access database
of itself and other servers in the system.
• So data traffic is comparatively very low in
distributed database system.
• This is a modern sophisticated database system
with high facilities and high operating cost.
47
C C C
1 2 3
DB1
DB2
DB3 Server 1
DB4
DB
C C C C
1 2 1 2
DB1
Network DB2
DB1 Server 4
DB2 Server 2 DB3
DB3 DB4
DB4 DB
DB
DB1
Server 3 DB2
DB3
DB4
DB
C C
1 2
48
Data Integrity and Data Security
• Data Integrity referees to the validity or consistency of
data in database. It ensures that the data should be
accurate and consistent.
• This is done by using different types of constraints
(rules) called integrity constraints.
• Ex 1: age of an employee is between 16 and 70
• Database security is protection of information in
database against unauthorized access, modification or
destruction.
• The authorized access means only right people can get
the right access to the right data.
• There are different causes of database destruction. It
might be accidental loss or physical damage in
computer system or. natural calamities.
• Different types of data recovery, data locking
techniques and (RAID: Redundant Array of
Independent Disk) are used.
49