0% found this document useful (0 votes)
9 views83 pages

DBMS-Module-1

The document provides an overview of database systems, including the purpose, architecture, and types of databases, emphasizing the differences between traditional file-based systems and database management systems (DBMS). It discusses the advantages and disadvantages of both systems, the roles of users and database administrators, and various data models and architectures. Additionally, it covers database languages, the Entity-Relationship model, and the importance of data independence.

Uploaded by

boddualekhya22
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
Download as pptx, pdf, or txt
0% found this document useful (0 votes)
9 views83 pages

DBMS-Module-1

The document provides an overview of database systems, including the purpose, architecture, and types of databases, emphasizing the differences between traditional file-based systems and database management systems (DBMS). It discusses the advantages and disadvantages of both systems, the roles of users and database administrators, and various data models and architectures. Additionally, it covers database languages, the Entity-Relationship model, and the importance of data independence.

Uploaded by

boddualekhya22
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1/ 83

VIT University

School of Computer
Science Engineering

Module 1
Introduction to Database System
Introduction to Database system
Purpose of database system, view of data,
Independence, relational databases, Database
Language, Database System architecture - levels,
Mappings,

Database users and DBA Data Models:


Importance, Basic building blocks, Degrees of data
abstraction.

Database design and ER Model: Overview, ER-


Model, Constraints, ER-Diagrams, ERD Issues,
weak entity sets.
Traditional file based System

• File system is collection of data. In this system,


user has to write procedures for
managing database. It provides details of data
representation and storage of data.
• If system crashes while entering some data,
then content of file will be lost. This is
disadvantage of traditional file based system.
Also, it is very difficult to protect a file under
the file system. This system can’t efficiently
store and retrieve data.
Advantages of Traditional File System

• Management and Maintenance cost is less.


• File processing design approach was well suited
for beginners.
• Supporting business applications domain to
store and mange data.
• It can be more efficient and cost less than DBMS
in certain situations.
• Design is simple.
• Customization is easy and efficient. So brings
user friendly operational environment.
Disadvantages of Traditional File System

• Data redundancy and inconsistency.


• Difficulty in accessing, manipulating and managing
data due to redundancy.
• Unauthorized access is not restricted.
• Data Recovery and Backup problem.
• System failure and crashing issues.
• Program & data dependence
• Fixed queries
What is Data

• Data is a collection of a distinct small unit of


information.
• It can be used in a variety of forms like text,
numbers, media, bytes, etc.
• it can be stored in pieces of paper or electronic
memory, etc.
• Word 'Data' is originated from the word 'datum'
that means 'single piece of information.'
• It is plural of the word datum.
• In computing, Data is information that can be
translated into a form for efficient movement and
processing.
6
What is Database?
 A database is an organized collection of data, so
that it can be easily accessed and managed.
 Some Examples
• Web indexes
• Library catalogues
• Medical records
• Bank accounts
• Product catalogues
• Telephone directories
• Airline bookings
• Credit card details
• Student records

7
WHY DBMS

• Defines (data types, structures, constraints) and


constructs (storing data on some storage medium
controlled by DBMS)

• Manipulates (querying, update, report generation,


etc…)
databases for various applications.

• A Database Management Software (DBMS) is


used for storing, manipulating, managing data and
to satisfy their specific (business) requirements.
DBMS (Data Base Management System)
Database management System is software which is
used to store and retrieve the database. For example,
Oracle, MySQL, etc.; these are some popular DBMS
tools.

 DBMS provides the interface to perform the various


operations like creation, deletion, modification, etc.
 DBMS allows the user to create their databases as
per their requirement.
 DBMS accepts the request from the application and
provides specific data through the operating system.
 DBMS contains the group of programs which acts
according to the user instruction.
 It provides security to the database.
9
DBMS APPLICATION

• Banking: all transactions


• Airlines: reservations, schedules
• Universities: registration, grades
• Sales: customers, products, purchases
• Manufacturing: production, inventory,
orders, supply chain
• Human resources: employee records,
salaries, tax deductions, etc…
File Management System Database Management System
File System is a general, easy-to-use system to store Database management system is used when security
general files which require less security and constraints are high.
constraints.

Data Redundancy is more in file management system. Data Redundancy is less in database management
system.

Data Inconsistency is more in file system. Data Inconsistency is less in database management
system.

Centralisation is hard to get when it comes to File Centralisation is achieved in Database Management
Management System. System.

User locates the physical address of the files to access In Database Management System, user is unaware of
data in File Management System. physical address where data is stored.

Security is low in File Management System. Security is high in Database Management System.

File Management System stores unstructured data as Database Management System stores structured data
isolated data files/entities. which have well defined constraints and interrelation.
ADVANTAGES

• REDUCED DATA REDUNDANCY


• ELIMINATION OF INCONSISTENCIES DATA
• DATA SECURITY
• EASIER DATA ACCESS
• IMPROVED DECISION MAKING
• BACKUP AND RECOVERY
DISADVANTAGES

• HIGH INITIAL COST RESOURCES


• COMPLEXITY
• COST OF CONVERSION IN SOME SITUATIONS
• SECURITY ISSUES
• SLOWER RESPONSE
EXAMPLES
• Oracle
• DB2 (IBM)
• MS SQL Server
• MS Access
• Clipper
• MySQL
• dBASE
• FoxPro
etc....
DBMS Environment
Components of Database System
• Users- People who interact with the database:
• Application Programmers.
• End Users.
• Data Administrators.
• Software- Lies between the stored data and the users:
• DBMS.
• Application Software.
• User Interface.
• Hardware- Physical device on which database resides.
• e.g.:
• Computers, Disk Drives,
• Printers, Cables etc.
• Data- numbers, characters, pictures.
• e.g.:
• NIOS, 1008, Noida, India.
Users of DBMS
• Application Programmers
The Application programmers write programs
in various programming languages to interact
with databases.
• Database Administrators
Database Admin is responsible for managing
the entire DBMS system.
• End-Users
The end users are the people who interact
with the database management system.
Database Administrator (DBA)

• Individual or a group, having centralized control of


the database.
• Has a good understanding of database and
coordinates all activities of the database.
• Functions:
-Defines schema.
-Defines storage structure and access method.
-Modification of both.
-Granting user authority to access the
database.
-Monitoring performance and responding to
changes.
Types of DBMS/ DBMS Models

• Hierarchical databases
• Network databases
• Object oriented databases
• Relational databases
Hierarchical DBMS(HDBMS)
 1968-1980 was the era of the Hierarchical
Database. Prominent hierarchical database
model was IBM's first DBMS.
 It was called IMS (Information Management
System).
 In this model, files are related in a parent/child
manner.
 Tree like structure.

20
Network DBMS
 A network database model is a database model
that allows multiple records to be linked to the
same owner file.
 In this model, files are related as owners and
members, like to the common network model.
Object oriented DBMS
Relational Database (Tabular)
 1970 - Present: It is the era of Relational
Database and Database Management. In 1970,
the relational model was proposed by E.F. Codd.
 Relational database model has two main
terminologies called instance and schema.
 The instance is a table with rows or columns
 This model uses some mathematical concept like
set theory and predicate logic.
 The first internet database application had been
created in 1995.
 During the era of the relational database, many
more models had introduced like object-oriented
model, object-relational model, etc.
23
Relational databases
DBMS Architecture
• The DBMS design depends upon its
architecture. The basic client/server
architecture is used to deal with a large
number of PCs, web servers, database
servers and other components that are
connected with networks.

• The client/server architecture consists of


many PCs and a workstation which are
connected via the network.

• DBMS architecture depends upon how


users are connected to the database to get
Types of DBMS Architecture
• 1-Tier Architecture
• In this architecture, the database is
directly available to the user. It means
the user can directly sit on the DBMS
and uses it.
• Any changes done here will directly be
done on the database itself. It doesn't
provide a handy tool for end users.
• The 1-Tier architecture is used for
development of the local application,
where programmers can directly
communicate with the database for the
2-Tier Architecture
• The 2-Tier architecture is same as basic
client-server. In the two-tier architecture,
applications on the client end can directly
communicate with the database at the server
side. For this interaction, API's
like: ODBC, JDBC are used.
• The user interfaces and application programs
are run on the client-side.
• The server side is responsible to provide the
functionalities like: query processing and
transaction management.
• To communicate with the DBMS, client-side
application establishes a connection with the
3-Tier Architecture
• The 3-Tier architecture contains another layer
between the client and server. In this architecture,
client can't directly communicate with the server.
• The application on the client-end interacts with an
application server which further communicates
with the database system.
• End user has no idea about the existence of the
database beyond the application server. The
database also has no idea about any other user
beyond the application.
• The 3-Tier architecture is used in case of large web
application.
Data Model
• Data modeling is the process of creating a simplified
diagram of a software system and the data elements it
contains, using text and symbols to represent the data
and how it flows.
• Data models provide a blueprint for designing a new
database or reengineering a legacy application. Overall,
data modeling helps an organization use its data
effectively to meet business needs for information.
• Defined as an abstract model that organizes data
description, data semantics, and consistency constraints
of data.
• It emphasizes on what data is needed and how it should
be organized instead of what operations will be performed
on data.
• It is a conceptual representation of Data objects, the
associations between different data objects, and the rules.
Classification

RELATIONAL STORAGE MEDIUM


E-R MODEL MODEL
Conceptual Model
• Also Known as High-Level Model
• Provide flexible data-structuring capabilities.
• It shows relationships among data (entity)
• Ensures data requirement of the users.
• Not concerned with representation, but its conceptual
form.
• Three Imp terms:
• Entity: Any object, exists physically or conceptually.
• Attribute: Property or characteristic of entity.
• Relationship: Association or link b/w two entities.
• These 3 terms make Entity-Relationship Model.
Representational (Internal) Model
• Representation of data stored inside a database.
• Describes the physical structure of the database.
• It uses the concepts which are close to the end-users.
• Classification:
• Hierarchical
• Relational
• Network
• It consider a database as a collection of fixed-size
records.
• It involve mapping the entities in the conceptual model
to the tables in the relational model.
• It is often referred to as the logical Model.
Physical Model

• It is the physical representation of the database


• It has the lowest level of abstractions
• It shows how the data is stored; they deal with
• Run-time performance
• Storage utilization and compression
• File organization and access methods
• Data encryption
• It is managed by the operating system (OS)
• It Provide concepts that describe the details of how data are
stored in the computer’s memory
Instances or State
• Database State:
• The actual data stored in a database at a particular
moment in time. This includes the collection of all the
data in the database.
• Also called database instance (or occurrence or
snapshot).
• The database schema changes very infrequently.
• The database state changes every time the database is
updated.

• Schema is also called intension.


• State is also called extension.
Example of a Database Schema
Example of a database state
Three-Schema Architecture
• Defines DBMS schemas at three levels:
• Internal schema at the internal level to describe physical
storage structures and access paths (e.g indexes).
• Typically uses a physical data model.
• Conceptual schema at the conceptual level to describe
the structure and constraints for the whole database for
a community of users.
• Uses a conceptual or an implementation data
model.
• External schemas at the external level to describe the
various user views.
• Usually uses the same data model as the conceptual
schema.
The Three-schema architecture

Conceptual
Or
Logical

Internal
Or
Physical
Data Independence
• Logical Data Independence:
• The capacity to change the conceptual schema without
having to change the external schemas and their
associated application programs.

• Physical Data Independence:


• The capacity to change the internal schema without
having to change the conceptual schema.
• For example, the internal schema may be changed when
certain file structures are reorganized or new indexes
are created to improve database performance
Database Languages
• It can be used to read, store and update the data in the
database.
• Types of Database Language :
DDL

• Stands for Data Definition Language


• It is used to create schema, tables, indexes, constraints,
etc. in the database.
• Using the DDL statements, you can create the skeleton of
the database.
• Tasks perform :
Create, Alter, Drop, Truncate, Rename,
Comment…..
DML
• Stands for Data Manipulation Language
• It is used for accessing and manipulating data in a database.
• It handles user requests.
• Tasks perform :
Select, Insert, Update, Delete, Merge, Call,
Lock Table…….
DCL

• Stands for Data Control Language


• It is used to retrieve the stored or saved data.
• This execution is transactional.
• It also has rollback parameters.
• Tasks perform :
Grant and Revoke …
TCL
• Stands for Transaction Control Language
• It is used to run the changes made by the DML statement.
• It can be grouped into a logical transaction.
• Tasks perform :
Commit and Rollback…
ER Basics-Entity Relational Model
 High-level conceptual data model diagram known
as E-R Diagram.
 Based on the notion of real-world entities and the
relationship between them.
 Helps you to analyze data requirements
systematically to produce a well-designed database.

45
E-R Diagram

• ER Diagram is a visual representation of data that


describes how data is related to each other.
• ER diagrams help to explain the logical structure of
databases.
• ER diagrams are created based on four basic
concepts:
 Entities
 Attributes
 Keys
 Relationships
ENTITY
• A real-world thing that is to be represented in our database.
• An entity can be place, person, object, event or a concept,
which stores data in the database.
• An entity is made up of some 'attributes' which represent
that entity.
 5 Types of entity
 Person: Employee, Student, Patient
 Place: Store, Building student
 Object: Machine, product, and Car
 Event: Sale, Registration, Renewal
 Concept: Account, Course
• A rectangle symbol is used for ENTITY representation..
• Group of similar entities- entity set
Attributes
• An attribute describes the property of an entity.
• E.g : student : name ,rollno, age…
• An attribute is represented as Ellipses in an ER diagram.

student

name rollno age


Types of Attributes
Types of Attributes Description
Simple attribute Simple attributes can't be divided any further.
Ex: Rollno, Class
Composite attribute It is possible to break down composite attribute.
Ex:- a student's full name may be further divided into first name,
second name, and last name.
Derived attribute This type of attribute does not include in the physical database.
However, their values are derived from other attributes present
in the database.
Ex:- Age should not be stored directly. Instead, it should be
derived from the DOB of that employee.

Multivalued attribute Multivalued attributes can have more than one values.
Ex:- A student can have more than one mobile number, email
address, etc.
Key Attribute The key attribute is used to represent the main characteristics of
an entity. It represents a primary key. The key attribute is
represented by an ellipse with the text underlined.
Ex: Rollno is a key attribute as it can identify any student
uniquely.

Single Valued Attribute Single valued attributes are those attributes which can take only
one value for a given entity from an entity set. Ex: Age, DoB,
Rollno, etc.
Key Attributes
• Keys play an important role in the relational
database.
• It is used to uniquely identify any entity or record
or row of data from the table. It is also used to
establish and identify relationships between tables.
• Types of Key Attributes
• Primary Key
• Candidate Key
• Super Key
• Alternate Key
• Foreign Key
• Composite Key
• Surrogate Key
Primary key and Candidate Key
• It is the first key used to identify one and only one instance of an
entity uniquely. An entity can contain multiple keys. The key which
is most suitable from those lists becomes a primary key.
• For each entity, the primary key selection is based on
requirements and developers.
• A candidate key is an attribute or set of attributes that can
uniquely identify a tuple.
• Except for the primary key, the remaining attributes are
considered a candidate key. The candidate keys are as strong as
the primary key.
• Super Key
• Super key is an attribute set that can uniquely identify a tuple. A super key
is a superset of a candidate key.
• Foreign key
• Foreign keys are the attribute of the table used to point to the primary key
of another table.
• Composite key
• Whenever a primary key consists of more than one attribute, it is known as
a composite key. This key is also known as Concatenated Key.
• Alternate key
• The total number of the alternate keys is the total number of candidate
keys minus the primary key
• Surrogate key
• Surrogate key also called a synthetic primary key, is generated when a new
record is inserted into a table automatically by a database that can be
declared as the primary key of that table . It is the sequential number
outside of the database that is made available to the user.
Student
Roll No. Regd. No. Name gender E-mail DOB
1 100100 Abc male abc@gmail.c 12-03-2003
om
2 100230 Xyz Female xyz@gmail.co 03-02-2001
m
3 100536 Pqr Female pqr@gmail.c 15-05-2002
om
4 100469 Dhr Male dhr@gmail.c 08-04-2002
om

Library Roll No Book Author Issue Date Return Date Penalty


Name
1 C++ Abc 2-3-2021 3-3-2021 0
2 C++ Ghs 3-1-2021 2-3-2021 0

1 Dbms abc 8-9-2021 6-10-2021 0


Department
Relationship
• It represents the association between entities.
• A relationship is represented by diamond shape in ER diagram
• Example:
• Employee works at a Department,
• A student enrolls in a course.
• A set of relationships of similar type is called a relationship
set.

student enrolls Course


Types of Relationships

One-to-one − One entity from entity set A can be associated


with at most one entity of entity set B and vice versa.

Example:- Patient : Bed(1:1)

57
One-to-many − One entity from entity set A can be associated
with more than one entities of entity set B however an entity
from entity set B, can be associated with at most one entity.

Father : Children (1:M)

58
Many-to-one − More than one entities from entity set A can be
associated with at most one entity of entity set B, however an
entity from entity set B can be associated with more than one
entity from entity set A.

Student : Slot (M:1)

59
Many-to-many − One entity from A can be associated with more
than one entity from B and vice versa.

Teacher : student (M:N)

60
Weak Entities
 A weak entity is a type of entity which doesn't have its key
attribute.

61
Strong Entity Weak Entity
Strong entity always have one Weak entity have a foreign key
primary key. referencing primary key of strong
entity.
Strong entity is independent of Weak entity is dependent on
other entities. strong entity.
A strong entity is represented by A weak entity is represented by
single rectangle. double rectangle.
Relationship between two strong Relationship between a strong and
entities is represented by single weak entity is represented by
diamond. double diamond.

Strong entity may or may not Weak entity always participates in


participate in entity relationships. entity relationships.
DATA CONSTRAINTS
• Constraints are the rules enforced on the data columns of a
table.
• This ensures the accuracy and reliability of the data in
the database.(INTIGRITY)
• TYPES :
NOT NULL
UNIQUE
DEFAULT
CHECK
Key Constraints – PRIMARY KEY, FOREIGN KEY
Domain constraints
Mapping constraints
Relationships: constraints
• The degree of a relationship type
• binary (connects 2 entity types)
• unary/ recursive (connects 1 entity type with itself) Degree
• complex (connects 3 or more entity types)
• Ternary (connects 3)

• Relationship constraints - cardinality


• One to One (1:1)
• One to Many (1:m)
• Many to One
• Many to Many (m:n) Multiplicity

• Relationship constraints – participation


• full/mandatory
• or partial/optional
64
Relationships: Degree

Entity1 Entity2
HasLinkWith
Binary relationship

S u p e rv is o r Supe rv ise s

Entity1
Staff Recursive (Unary) relationship
- example
S u p e rv is e e

Entity1 Entity3
Te rnaryRe lationship

Complex relationship

here ternary Entity2

65
Relationships: Multiplicity
label lines to show cardinality and participation
0..1 “zero or one” optional
0..* “zero or more”
1..1 “one”
1..4 “between 1 and 4” mandatory
1..* “one or more”

Entity1 Entity2
HasLinkWith

1..1 0..*

Entity1 has a 1:m relationship with Entity2;


participation for Entity1 is mandatory, for Entity2 optional.
66
Relationships example

Manages
Manager Department
1..1 0..3

Manages
responsibility [1..*]
dateAllocated
Each manager
Each manages UP TO 3
department departments
is managed Relationship (but need not
by ONE attributes manage any
manager department) 67
FEATURES OF ER-diagram
Generalization
• Generalization is like a bottom-up approach in which two or
more entities of lower level combine to form a higher level
entity if they have some attributes in common.
• Entities are combined to form a more generalized entity, i.e.,
subclasses are combined to make a superclass.

IS A
Specialization
• This is a top-down approach, and it is opposite to
Generalization.
• This is used to identify the subset of an entity set that shares
some distinguishing characteristics.

IS A
Aggregation
• Where the relation between two entities is treated as a single
entity.
• Where relationship with its corresponding entities is
aggregated into a higher level entity.

ENQUIRE
E-R Diagram Steps
Here we are going to design an Entity Relationship (ER) model
for a college database . Say we have the following statements.
1. A college contains many departments
2. Each department can offer any number of courses
3. Many instructors can work in a department
4. An instructor can work only in one department
5. For each department there is a Head
6. An instructor can be head of only one department
7. Each instructor can take any number of courses
8. A course can be taken by only one instructor
9. A student can enroll for any number of courses
10. Each course can have any number of students 72
Step 1 : Identify the Entities

What are the entities here?


From the statements given, the entities are
1. Department
2. Course
3. Instructor
4. Student

73
Step 2 : Identify the relationships
1. One department offers many courses. But one particular course
can be offered by only one department. hence the cardinality
between department and course is One to Many (1:N)
2. One department has multiple instructors . But instructor belongs
to only one department. Hence the cardinality between
department and instructor is One to Many (1:N)
3. One department has only one head and one head can be the
head of only one department. Hence the cardinality is one to
one. (1:1)
4. One course can be enrolled by many students and one student
can enroll for many courses. Hence the cardinality between
course and student is Many to Many (M:N)
5. One course is taught by only one instructor. But one instructor
teaches many courses. Hence the cardinality between course and
instructor is Many to One (N :1)
74
Step 3: Identify the key attributes
• "Department_Name" can identify a department uniquely.
Hence Department_Name is the key attribute for the Entity
"Department".
• Course_ID is the key attribute for "Course" Entity.
• Student_ID is the key attribute for "Student" Entity.
• Instructor_ID is the key attribute for "Instructor" Entity.

Step 4: Identify other relevant attributes


• For the department entity, other attribute is location
• For course entity, other attributes are course_name,duration
• For instructor entity, other attributes are first_name,
last_name, phone
• For student entity, first_name, last_name, phone
75
Step 5: Draw complete ER diagram
By connecting all these details, we can now draw ER diagram as
given below.

76
BANKING SYSTEM
• ER diagram of Bank has the following description :

• Bank have Customers.


• Banks are identified by a name, code, address of main office.
• Banks have branches.
• Branches are identified by a branch_no., branch_name, address.
• Customers are identified by name, cust-id, phone number,
address.
• Customer can have one or more accounts.
• Accounts are identified by account_no., acc_type, balance.
• Customer can avail loans.
• Loans are identified by loan_id, loan_type and amount.
• Account and loans are related to bank’s branch.
1
Library Management System
• The system keeps track of the staff with a single point
authentication system comprising login Id and password.
• Staff maintains the book catalog with its ISBN, Book title,
price(in INR), category(novel, general, story), edition, author
Number and details.
• A publisher has publisher Id, Year when the book was published,
and name of the book.
• Readers are registered with their user_id, email, name (first
name, last name), Phone no (multiple entries allowed),
communication address. The staff keeps track of readers.
• Readers can return/reserve books that stamps with issue date
and return date. If not returned within the prescribed time
period, it may have a due date too.
• Staff also generate reports that has readers id, registration no of
report, book no and return/issue info.
Hospital Management System

You might also like