Professional Documents
Culture Documents
Unit I - Introduction
Unit I - Introduction
Overview of Database
Database
Systems
• A Database is a collection of interrelated data.
• Designed to meet the information needs of
an organization.
• Eg. A university Database – It contains information about students,
faculty, courses, classroom etc. It could also contains the information
about which student is studying which course.
Database
CourseDetails
Example
CourseID CName CFees Level
1 MBA 28000$ 9
2 MCA 30000$ 9
Advantages
Flexibility to change data structures:
of Database
Database structure may evolve as new requirements are defined.
Availability of current information:
Extremely important for on-line transaction systems such as airline, hotel, car
reservations.
Economies of scale:
Wasteful overlap of resources and personnel can be avoided by consolidating data and
applications across departments.
Disadvantages of DBMS
• Size – Database management system needs large amount
of disk space, internal memory.
• Expensive – Mainframe DBMS is very expensive.
• Additional Hardware requirement – Depending upon the
complexity of the DBMS, additional hardware may be
required
• Complexity
Three Schema Architecture/
Three level Data abstraction
Three Level Architecture of DBMS
continue…
External
View 1 View 2 View 3
Level
Conceptual
Level
Physical
Level
Three Level Architecture of DBMS
continue…
Sales Officer Inventory Controller
View 1 View 2
External Item_Name Item_Name
Level Price Stock
Conceptual
Conceptual Item_Number Character (6)
Item_Name Character(30)
Level Price Numeric(5,2)
Stock Numeric(4)
Physical
Stored_Item Length=50
Physical Item # Type = Byte(6), offset = 0, Index = Ix
Name Type = Byte(30), offset = 6
Level Price Type = Byte(8), offset = 36
Stock Type = Byte(4), offset = 44
Physical Level
• Lowest level of abstraction
• Describes how the data are actually stored.
• Describes low level data structures in detail.
Logical Level
• Describes what data are stored in the database, What
relationship exist among them.
• Database Administrator use the logical level of abstraction.
View Level
• The highest level of abstraction describes only the part of the
entire database
• Allows to see only the data of interest to them.
• Users – Application programmers or end-users
External or View Level
By Jismy Joseph
Data models, Schemas , and
Instances
Data models
Data Model
• Three data models that are used for
database management are:
1. The Relational Data Model
2. The Hierarchical Data Model
3. The Network Data Model
4. Entity-Relationship Model
The Relational Data Model
• In this model,the data is organized into
tables (ie., rows and columns). These
tables are called relations.
• A row in a table represents a relationship
among a set of values.
Consider a sample database with three
tables (relations):Suppliers, Items,
Quantities:
Suppliers (sup-no#,sup-name,status,
city)
Items ( item-no#, item-name, price)
Quantities (sup-no#, item-no#, Qty)
Suppliers
Sup-no# Sup-Name Status City
S1 Britannia 10 Delhi
S2 New 30 Mumbai
S3 Cockg 10 Delhi
Items
Item-no# Item-name Price
I1 Milk 15.00
I2 Cake 5.00
I3 Bread 9.00
I4 Biscuit 14.00
I5 Ice cream 6.00
I6 Jam 10.00
Quantities
Sup-no# Item-no# Qty
S1 I2 10
S1 I3 20
S1 I6 20
S2 I4 20
S2 I5 10
S3 I1 10
Rows of relations are generally referred to
as tuples or records and the columns are
usually referred to as attributes or
field.
No two tuples are identical and their
ordering is not important.
10 20 20 20 10 10
I2 Cake 5
I3 Bread 9
10
I6 Jam 10
20
20
S2 New 30 Mumbai
I4 Biscuit 14
I5 Icecream 6
20
10
S3 Cockg 10 Delhi
I1 Milk 15
10
In this tree structure supplier record type
is the root node.
Here the relationship is expressed in the
form of a tree with all the edges
pointing to the leaf.
The operations on a hierarchical database
are performed through a data manipulation
language for hierarchical data model.
The various operations include retrieval,
insertions , deletions and modifications
of records.
Entity-Relationship (ER) Model
• Entity-Relationship (ER) Model is based on the notion of real-world entities and relationships among
them.
• ER Model is best used for the conceptual design of a database.
• ER Model is based on −
Entities and their attributes.
Relationships among entities.
• Entity − An entity in an ER Model is a real-world entity having properties called attributes. Every attribute is
defined by its set of values called domain. For example, in a school database, a student is considered as an
entity. Student has various attributes like name, age, class, etc.
• Relationship − The logical association among entities is called relationship. Relationships are mapped with
entities in various ways. Mapping cardinalities define the number of association between two entities.
• Mapping cardinalities −
one to one
one to many
many to one
many to many
Schemas and Instances
By Jismy Joseph
Schemas versus Instances
• Database Schema:
• The description of a database.
• Includes descriptions of the database structure, data types, and the
constraints on the database.
• Schema Diagram:
• An illustrative display of (most aspects of) a database schema.
• Schema Construct:
• A component of the schema or an object within the schema, e.g., STUDENT,
COURSE.
Slide 2- 46
By Jismy Joseph
continue…
Sales Officer Inventory Controller
View 1 View 2
External Item_Name Item_Name
Schema Price Stock
Conceptual
Conceptual Item_Number Character (6)
Item_Name Character(30)
Schema Price Numeric(5,2)
Stock Numeric(4)
Physical
Stored_Item Length=50
Physical Item # Type = Byte(6), offset = 0, Index = Ix
Name Type = Byte(30), offset = 6
Schema Price Type = Byte(8), offset = 36
Stock Type = Byte(4), offset = 44
By Jismy Joseph
Example of a Database Schema
Slide 2- 49
Schemas versus Instances
• 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 term instance is also applied to individual database components, e.g. record
instance, table instance, entity instance
Slide 2- 50
Database Schema
vs. Database State
• Database State:
• Refers to the content of a database at a moment in time.
• Initial Database State:
• Refers to the database state when it is initially loaded into the system.
• Valid State:
• A state that satisfies the structure and constraints of the database.
Slide 2- 51
Example of a database state
Slide 2- 52
Database Schema
vs. Database State (continued)
• Distinction
• The database schema changes very infrequently.
• The database state changes every time the database is updated.
Slide 2- 53
DBMS Languages
DBMS Languages
Structured Query Language(SQL)
• SQL is a Language designed for managing data in relational database
management system(RDBMS).
• SQL is a relational database language, not a programming language like C, C++.
• It is flexible, simple and powerful.
Components of SQL – SQL has three components. They are:
• DDL - Data Definition Language
• DML - Data Manipulation Language
• DCL - Data Control Language
The Data Definition Language
(DDL)
The Data Definition Language (DDL):
• DDL commands are used to deal with the schema (structure) definition of the RDBMS.
• DDL command are used to create, modify and remove database objects such as tables,
views and.
• Integrity constraints can be defined on tables, either when the table is created or later.
• For eg: CREATE, ALTER, DROP commands
The Data Definition Language
(DDL)
The Data Definition Language (DDL):
• Used by the DBA and database designers to specify the conceptual
schema of a database.
• In many DBMSs, the DDL is also used to define internal and external
schemas (views).
• In some DBMSs, separate storage definition language (SDL) and view
definition language (VDL) are used to define internal and external
schemas.
The Data Manipulation Language
(DML)
The Data Manipulation Language (DML):
• DML command enhances efficient user interaction with the database
system by providing a set of commands.
• DML permits users to insert data into the table, retrieve existing data,
delete data from tables and modify the stored data.
• The common DML commands are SELECT, INSERT, UPDATE and DELETE.
The Data Manipulation Language
(DML)
The Data Manipulation Language (DML):
• DML commands (data sublanguage) can be embedded in a
general-purpose programming language (host language),
such as COBOL, C, C++, or Java.
• Alternatively, stand-alone DML commands can be applied
directly (called a query language).
Types of DML
• High Level or Non-procedural Language:
• To specify complex database operations.
• Many DBMS allow high-level DML statements either to be entered
interactively from display monitor or terminal or to be embedded in a general
purpose programming language.
• For example, the SQL relational language
• Are “set”-oriented and specify what data to retrieve rather than how to
retrieve it.
• Also called declarative languages.
• Low Level or Procedural Language:
• Low Level DML must be embedded in a general purpose programming
language.
• Retrieve data one record-at-a-time;
• Constructs such as looping are needed to retrieve multiple records, along with
positioning pointers.
The Data Control Language
(DCL)
The Data Control Language (DCL):
• DCL is used to control access to the database, which is very essential to a database
system with respect to security concern.
• DCL commands that control a database, including administering privileges and
committing data.
• The commands GRANT and REVOKE are used as a part of DCL.
The Database System
Environment
DBMS component Modules
Typical DBMS Component Modules
• The top part of the figure refers to the various
users of the database and their interfaces.
• The lower part shows internal modules of the
DBMS responsible for storage of data and
processing of transaction.
• The database and database catalog are
usually stored on disk
• Access of disk is primarily controlled by the
OS.
Users
DBMS Software
Data store
Hardware