DATABASE MANAGEMENT
Chapter 2
Database System
Architecture
Contents
• Database System Architecture
• Mapping
• Data Independence
• Data Dictionary
• Database Language
• Data Models
• Hierarchical Data Model
• Network Data Model
Database System Architecture
Chapter 2 - Database System Architecture
Database System Architecture
• Database system provides users with an abstract view of data
• Data View → Presentation of data for users
• Same data in database can be viewed in different ways and formats
• Hides certain details of how data is stored and manipulated
• Before designing database, data of an organization is considered on an
abstract level
• "abstract" means theoretical or conceptual
• Abstract view is not an actual view of something
• When we see an actual computer system, it looks different
• It is just a model to understand something
• Database gives an abstract view, not an actual view of data
Database System Architecture
• Database system architecture → design or construction aspects of database
system
• Basically a software system, it also possesses architecture
• Must define a particular configuration of interaction between data, software
modules, meta-data, interfaces, and languages
• Provides a general concept and structure of database system
• Architecture of most commercial database systems is based on a three-level
architecture proposed by Data Base Task Group (DBTG)
Three-Level Architecture
• 1971 → DBTG (Data Base Task Group) developed and published a proposal for a
standard vocabulary (or language) and architecture for database system
• appointed by CODASYL (Conference on Data Systems and Languages)
• 1975 → similar architecture and vocabulary were developed and published by
SPARC (Standards Planning And Requirements Committee) of the American National
Standards Institute (ANSI)
• As a result of these and later reports → databases can be viewed at three levels
• External Level, Conceptual Level, and Internal Level
• Levels form three-level architecture
• Three-level schema → Represented by three schemas or three models
• The models refer to the structure of a database, not to the data that is stored in it
• Intension of the database, or database schema → structure of a database
• Extension of database, or database instance → data stored in database at a given
time
• Extension of database is performed after intension of database has been finalized
• data is stored in the database after defining the structure of database
Three-Level Architecture
• Purpose → to create a separation
between physical database and user
applications
• Hide details of physical storage from
user
• DBA should be able to change the
structure of database storage without
affecting user’s view and user
applications
Three-Level Architecture
• External Level
• External level or view level is closest to users
• Concerned with the way data is viewed by individual users
• Most of the users do not require the entire data stored in database
• External level describes a part of database that is required for a particular user
• Each user can access data according to his/her requirements
• User → an application programmer or an end-user, but DBA is an important special case
• Consists of different external views of data stored in a database
• Each view represents data of a database that is relevant to a particular user and hides
other parts of database from that user
• Different views may have different representations of same data
• For example,
• one user may view date → format (day, month, year)
• another may view date → format (year, month, day)
Three-Level Architecture
• External Level
• Some users may view virtual or calculated data
(not stored in database)
• Calculated data → created temporarily when needed
• If obtained marks in different subjects of students
are stored in database
• Calculate total marks, average marks, and grades
• If date-of-birth of a student is stored in database
• Can find age of student
• View may include data combined or calculated
from several records
• External record is a record as seen by a particular
user, which is a part of his/her external view
• External view → collection of external records
Three-Level Architecture
• External Level
• Defined in external schemas (subschemas)
• External Schemas → written in Data Definition Language (DDL)
• DBA writes an external schema to create a user view
• User View → A logical description of some portion of database that is required by a user
• Compiled by DBMS and stored in its data dictionary
• DBMS uses external schema created for a specific user, to create a user interface to
access data of database
• User-interface created through external schema accepts and displays information in
the format user expects
• Also acts as a barrier to hide information from user that is not permitted to him
• Hides the conceptual, internal, and physical details of database from user
• If any user needs some advance access of database
• such as to change existing record
• Then → external schema for that user is re-written (modified) by DBA to allow access to him
Three-Level Architecture
• Logical or Conceptual Level
• Middle-level view in three-level architecture
• Describes the structure of whole database
• Explains what data to be stored in database and what relationships exist among
those data
• Hides the details of physical storage structures
• i.e. implementation of the data structure is hidden
• Database security and constraints (or integrity rules) are also implemented in this
level of architecture
• Programmers and DBA work at this level (Mostly, maintained by DBA)
• Supports external level to present data to end-users as they need
• Comparatively constant
• DBA designs it after determining the present and future information needs of the
organization
• If there is any change in the external level or view, the conceptual level should be able to
accommodate that change
Three-Level Architecture
• Logical or Conceptual Level
• Defined in conceptual schema
• Conceptual schema → complete description of data structure of databases
such as field names, their types, and size
• Also includes security and integrity rules
• There is only one conceptual schema per database
• Written in DDL
• Compiled by DBMS and stored in its data dictionary
• DBMS uses conceptual schema to create logical record interface, which
defines and creates the working environment for the conceptual level to
present data to end-users
• Conceptual level is a collection of logical records
Three-Level Architecture
• Internal or Physical Level
• Closest to physical storage of data
• Describes physical storage structures of database and file organizations used to store data on physical storage
devices
• Physical level describes how data is stored on storage devices
• Works with operating system and DBMS for storing and retrieving data to and from the storage devices
• Internal level and physical level are considered to be same, but there is a slight difference
• Physical level → managed by operating system under direction of DBMS
• Internal level → is managed by DBMS
• Internal record is a single stored record
• Storage unit that is passed up to the internal level through a stored record interface
• Stored record interface is boundary between physical level and internal level
• This interface is provided to DBMS by operating system
• In some cases, DBMS itself may create this interface
• Physical level below this interface consists of data which is stored and managed by operating system
• Operating system creates physical record interface to access the data stored on storage devices
• Internal level → described in internal schema, which defines various record types, storage space allocation for
data and indexes, etc.
• Written in DDL
Mapping
Chapter 2 - Database System Architecture
Mapping
• Three levels of database architecture are described by
three schemas
• These schemas are stored in data dictionary
• In DBMS, each user refers only to its own external
schema
• DBMS → to store & retrieve data
• transform a request on a specified external schema
• into a request against conceptual schema
• Then, into a request against an internal schema
• Mapping → process of converting a request (from
external level) and the results from one level to another
level
• Defines the correspondence between three levels
• Mapping description is stored in data dictionary
• DBMS is responsible for mapping between these three
types of schemas
Mapping
• External-Conceptual Mapping
• Defines the correspondence
between a particular external view
and conceptual view
• Tells the DBMS which objects on the
conceptual level correspond to the
objects requested on a particular
user’s external view
• If changes are made to either an
external view or conceptual view,
• then mapping must be changed
accordingly
Mapping
• Conceptual-Internal Mapping
• Defines the correspondence between
conceptual view and internal view
• i.e. database stored on physical storage
device
• Describes how conceptual records are
stored and retrieved to and from storage
device
• Tells DBMS that how conceptual records
are physically represented
• If structure of stored database is changed
• then the mapping must be changed
accordingly
• Responsibility of DBA to manage such
changes
Mapping
• Conceptual-Internal Mapping
• Suppose some records of students are stored at physical level
• User-1 → requests record of a particular student through user-interface
• DBMS → receives request and checks user’s external schema, external-conceptual mapping, and conceptual schema in data
dictionary
• DBMS → checks user’s authorization to access the record
• If user not authorized → request rejected
• If authorized user → request is passed to conceptual level
• DBMS uses logical record interface to request logical record
• DBMS → checks conceptual-internal mapping to see corresponding internal structure
• DBMS identifies internal objects or items that are required
• On physical level → records of students are stored (stored record)
• OS is responsible to search correct block that contains requested record on disk and to retrieve it
• A block may contain multiple records
• Retrieved block of records is placed in buffer in memory and OS passes address of required record within
buffer to DBMS
• DBMS receives only requested complete record of student in coded form (as it is coded i.e. in binary form)
from the buffer
• DBMS uses conceptual-internal mapping to decide which items pass to the conceptual level through a logical
record interface
Mapping
• Conceptual-Internal Mapping
• At conceptual level → complete record appears as a logical record in readable
form (coding is removed)
• DBMS checks external-conceptual mapping to decide how the record is displayed and
which items (or fields) of the record are to be displayed
• Data of record is passed to external level through user-interface for displaying
and to perform various operations by user
• At external level → same record may be displayed (as an external record) in
different formats for different users
Data Independence
Chapter 2 - Database System Architecture
Data Independence
• Separation of data from application programs (or user-interfaces)
• Nearly all modern applications are based on the principle of data
independence
• Three-level architecture provides concept of data independence
• upper-levels are not affected by changes to lower-levels
• Three-level architecture makes it easier to achieve true data independence
• User can change structure of a database without changing application program
• Kinds of data independence
• Logical data independence
• Physical data independence
Data Independence
• Logical Data Independence
• Separates external level from conceptual level
• Enables a user to change conceptual level without
changing external level or application programs
• Occurs at user interface level
• Changes in conceptual level → addition or removal of
entities, attributes, or relationships
• These changes should be possible without having to
change external level or application programs
• More difficult to achieve since application programs are dependent on logical
structure of data that they access
• In some situations, problems can be created by changing logical structure of
database (or conceptual schema)
• Suppose → delete some attributes from database structure
• Application program that is using these attributes may not run any more
Data Independence
• Physical Data Independence
• Separates conceptual level from internal level
• Enables a user to change internal level without changing conceptual level
• Occurs at logical interface level
• In DBMS, physical structure of database can be changed without modification in
application programs
• Conceptual or logical level remains constant
• Application programs and interactions of users based on conceptual level
• Not affected by any change in internal level
• Changes in the internal level
• Using new storage devices for storage
• Using different data structures
• Changing access methods
• Changing file organizations or storage structures
• Modifying indexes
• Easy to achieve and implement than logical data independence
Data Dictionary
Chapter 2 - Database System Architecture
Data Dictionary
• Data repository or system catalog
• Contains information about database or collection of databases
• Does not contain any actual data of database(s)
• Contains only bookkeeping information for managing database(s)
• Data dictionary contains metadata (i.e. data about data)
• Information in data dictionary
• Logical structure of database → table names, column names of each table and their data types
and other properties, constraints that apply to each field (if any), and stored procedure names
• Schemas, mappings, and constraints
• Description about application programs
• Description about physical database design such as storage structures, and access paths
• Descriptions about users of DBMS and their access rights
• Also keeps a record of accessing database
• Without data dictionary → DBMS cannot access data from database
• Most DBMSs keep data dictionary hidden from users to prevent them from
accidentally destroying its contents
Data Dictionary
+Provides actual structure of database(s)
+ Administrators and other users can easily access structure of database(s), without accessing it
+When developing programs that use data model, a data dictionary can be consulted
to understand where a data item fits in structure, and what values it may contain
• Integrated Data Dictionary
• Data dictionary which is a part of DBMS
• In most DBMSs, data dictionary is integrated and active
• DBMS checks this type of data dictionary every time database is accessed
• Automatically maintained by the system
• Freestanding Data Dictionary
• Data dictionary which is a separate part of DBMS (non-integrated data dictionary)
• May be a commercial product or a simple file developed and maintained by a
database designer
• Useful in initial stage of design for collecting and organizing information about data
Database Language
Chapter 2 - Database System Architecture
Database Language
• Used to access required data, to modify data, and to design structure of database
• User uses a database language for interfacing with DBMS to access data
• User can either be an application programmer or an end-user
• Mostly, application programmer inserts statements of database access language into an application
program written in a general-purpose programming language
• Programming language → COBOL or C++ or Visual Basic or any fourth-generation language (4GL))
• Also known as data sub-language
• Does not provide complete programming language features
• Many DBMSs have their own unique data sub-languages
• Users use database access language to enter new data, change existing data, and to retrieve
required data from databases
• User writes a set of appropriate commands or statements in a database access language and
submits these to the DBMS
• DBMS translates user commands and sends them to a specific part of DBMS (database engine)
• Database engine → generates a set of results according to statements submitted by user
• It converts these results into a user-readable form → Inquiry Report
• then displays them on screen
• DBA use database access language to create, modify, and maintain the databases
Database Language
• Most popular database access language → SQL (Structured Query Language)
• Relational Databases are required to have a database query language
• Most RDBMSs use SQL as database access language
• In MS Access → SQL statements are also used to perform different operations
on databases
• These operations are normally hidden from users
• Classification of Database Languages
• Data Definition Language (DDL)
• Data Manipulation Language (DML)
• Data Control Language (DCL)
• Transaction Control Language (TCL)
Database Language
• Data Definition Language (DDL)
• Used to define structure of a database, especially database schemas
• Subset of SQL
• Has a pre-defined syntax for defining structure of database
• DBA and database designers use database language to define conceptual and
internal schemas
• In most DBMSs, DDL is used to define both conceptual and external schemas
• DBMS has a DDL compiler, which compiles DDL statements and stores in the
DBMS catalog (data dictionary)
• CREATE Statement
• Used to create different database objects
• Objects → table, view, index, constraint, and procedures, etc.
Database Language
• Data Definition Language (DDL)
• USE Statement
• Used to change current database in DBMS
• Whenever DBA or designer connects to a DBMS like Oracle or SQL server → connected to a default
database
• Can connect to another database with the help of USE command
• USE college;
• ALTER Statement
• Used to change properties of a database object
• ALTER TABLE result ADD total_marks INTEGER;
• DROP Statement
• Used to delete a database object
• DROP TABLE employees;
• Can also be used to drop a database index or other objects
• TRUNCATE Statement
• Used to delete data from database table
• TRUNCATE TABLE employees;
Database Language
• Data Manipulation Language (DML)
• Once database is designed & populated with data
• DML is used to manipulate database
• In data manipulation → data is retrieved, inserted, updated, and deleted to and from
the database
• DML applies to external, conceptual, and internal levels
• DDL is not used for data manipulation
• Application programmer can insert (or embed) DML statements into program written
in a general-purpose language
• General-purpose programming language → Host Language
• DML → Data Sub-Language
• Host languages → COBOL, C++, and Visual Basic
• Provides facilities to perform computational operations
• A given DBMS might support any number of host languages and any number of data
sub-languages
• Data sub-language → SQL
• Supported by almost all database systems
Database Language
• Data Manipulation Language (DML)
• SELECT Statement
• Used to retrieve records from one or more database tables or database views
• Can retrieve selected data of specific records according to our requirements
• SELECT * FROM employees;
• SELECT EmpNo, EName FROM employees;
• INSERT Statement
• Used to insert one or more records into a single table
• Must be used keeping in mind the underlying database constraints, otherwise, this statement will not work and will
display an error for user
• INSERT INTO phone_book (name, NUMBER) VALUES ('Naeem', '0300-1212345');
• UPDATE Statement
• Used to change or update data of one or more records in a table
• Frequently used in environments where already added data needs to be changed afterward
• For example, in a banking environment → balance of customers’ accounts is updated whenever cash deposits or cash withdrawals
are made
• Normally used with WHERE clause
• UPDATE employees SET PName = ’Khalil’ WHERE EmpNo = 245;
• DELETE Statement
• Used to remove/delete one or more records in a table
• Allowed to use only a few authorized users in a database environment
• Wrong use of this statement may delete important data of an organization
• Also used with WHERE clause
• DELETE FROM employees WHERE EmpNo = 245;
Database Language
Types of Data Manipulation Language (DML)
• Non-Procedural DML
• High-level query language
• Allows end-users to give their requests to DBMS to retrieve required data
• A single statement is given to DBMS to retrieve or update multiple records
• DBMS translates a DML statement into a procedure that manipulates the set of records
• Examples → SQL and QBE (Query-By-Example)
• Used by relational database systems
• Easier to learn and use
• Query Language → part of a non-procedural DML, which is related to data retrieval
• Procedural DML
• Low-level query language
• Typically retrieves individual records from database and processes each separately
• Looping and branching statements are used to retrieve and process each record from a
set of records
• Programmers use low-level DML
Database Language
• Data Control Language (DCL)
• Used to control access to data stored in a database
• Used to create rights (privileges) of users to access and to manipulate data
• Part or component of Structured Query Language (SQL)
• Only DBA or an expert user uses DCL statements
• GRANT Statement
• Used to provide (or set) user access permission or privileges (rights) to a database
• Authorizes one or more users to perform different operations on a database object
• GRANT SELECT, UPDATE ON employees TO user1, user2;
• REVOKE Statement
• Used to take back access permission from users given with the GRANT statement
• REVOKE SELECT, UPDATE ON employees FROM user1, user2;
Database Language
• Transaction Control Language (TCL)
• Used to manage or control transactions in a database
• Different transactions are made by DML statements
• Transaction → a single unit of work including some modifications in a database
• If transaction is successful → all data modifications made during transaction
are committed (i.e. saved)
• and become a permanent part of database
• If transaction encounters an error → all modifications must be rolled back
• i.e. come back to the initial stage
• TCL statements ensure data consistency and group logically related statements
together in a database environment
• Part or subset of Structured Query Language (SQL)
Database Language
• Transaction Control Language (TCL)
• COMMIT Statement
• Used to confirm all data modifications during a transaction
• These changes are permanently saved into database
• ROLLBACK Statement
• Used to undo all changes of a transaction in a database
• This statement is used in case an error is encountered in a
transaction
• If there is an error then ROLLBACK statement will be executed
• otherwise, the COMMIT statement will save all data
modifications
• SAVEPOINT Statement
• Used to temporarily save a part of transaction so that it can be
rollbacked to that point whenever necessary
• A transaction is divided into smaller sections
• Breakpoints for a transaction are defined to allow partial
rollbacks
• The ROLLBACK TO statement rollbacks the parts of a
transaction, instead of whole transaction
Data Models
Chapter 2 - Database System Architecture
Data Models
• Model → Representation of a real-world object, process, event, device, or
concept and their associations
• helps users to understand the complex object or system
• provides valuable information about it
• For example:
• atomic model →shows orbital movement of electrons around nucleus
• nuclear model → shows process of a nuclear reactor
• Data model (or database model) → collection of concepts that can be used to
describe structure of a database
• data types, relationships between data, and constraints that should hold on data are
described
• also describes how data will be stored, accessed, updated, and processed or
manipulated in a database system
• Purpose → is to represent data and to make the data understandable for
others
• Database designer can easily design a database
Data Models
Parts of Data Model
• Structural Part
• Consists of a set of rules needed for the creation of databases
• Manipulative Part
• Defines the types of operations that can be performed on data of database
• Types of operations → retrieving data from database, updating data, changing structure of database, etc.
• Set of Integrity Rules
• Specifies various constraints on data of the database
• Integrity rules ensure accuracy and consistency of data that is to be entered into database
• In database design, data of an organization is represented by developing a data
model
• A well-developed data model helps database designers to understand data of an
organization for which database design is developed
• Provides a clear picture of data of an organization
• Used as a communication tool for database designers, application programmers, and
end-users to interact with each other
• Helps database designers for designing a proper and successful database
Data Models
Conceptual Data Models
• High-level data model, heart of database design
• Represents permanent structure of data resource of an organization
• Most important and major task in database design is to develop conceptual data
model
• If conceptual data model is developed accurately → it can easily be converted into a
physical data model
• External views can also be created very easily
• If a poor conceptual model is developed → many problems may have to be faced
during the implementation of database
• Difficult to categorize since each represents an alternate approach to design data of
an organization
• Categorized according to types of concepts used to design the data of an
organization
• Object-based Data Models
• Record-based Data Models
Data Models
Conceptual Data Models
• Object-based Data Models
• Used to describe data at conceptual level
• Specify what is to be stored in database
• Use concepts such as entities/objects, attributes, and relationships between
entities/objects
• Important object-based data models
• Entity-Relationship Model (E-R model)
• Semantic Object Model
• Object-Oriented Model
Data Models
Conceptual Data Models
• Record-Based Data Models
• Stand between conceptual data models and physical data models
• Representational or implementation data models
• Used to describe conceptual, external as well as internal levels of the database
• Provide concepts that may be understood by end-users but hide some details
of data storage
• Represent data by using record structures → record-based models
• Used in traditional commercial DBMS
• Hierarchical data model
• Network data model
• Relational data model
Data Models
Physical Data Models
• Low-level data models
• Provide concepts that describe details of how data is stored on storage devices
• Provide information about data storage structures, ordering of records on the
storage devices, and data access paths
• Internal or physical model is just the physical implementation of conceptual
model
• Internal model should change when new devices or new techniques for
representing data and improving performance are developed
Hierarchical Data Model
Chapter 2 - Database System Architecture
Hierarchical Data Model
• Oldest data model in which data is organized in a tree-like structure
• parent and child nodes
• Hierarchy starts from root node and expands like a tree by adding child nodes to
parent nodes
• Nodes of tree represent records (or record segments)
• Edges connecting the nodes represent relationships
• A node may have any number of child nodes, but each child node may have only one
parent node
• Each node is related to others in a parent-child relationship
• Records have a parent-child relationship or one-to-
many relationship (because a parent has many
children)
• For example, in a College system, one department
of a college can have many courses, many
professors, and many students.
Hierarchical Data Model
• Information management system (IMS) of IBM is one of the most popular
hierarchical management systems
• Developed for USA space program to organize and store information
• North American Aviation (NAA) and IBM worked jointly to produce first version
of IMS
• released in 1968
• IMS is still most widely used hierarchical DBMS on IBM mainframe computers
• Another important hierarchical DBMS is System 2000 from Intel Corporation
Hierarchical Data Model
+Simplicity - Implementation complexity
+Searching - Database Management Problem
+Easy addition and deletion of data - Lack of Structural Independence
+Data Security - Operational Anomalies
+Data Integrity - Difficult to Reorganize
+Performance
Note: Details are given in PM Series book
Network Data Model
Chapter 2 - Database System Architecture
Network Data Model
• Modified version (or extension) of hierarchical data model
• Data is organized like a graph (or network-like structure) and each node can
have multiple parent nodes
• A complex graph or diagram may be used to represent structure of database
• Nodes represent records and edges represent relationships
• It is not possible that any node can have two or more parents
• Was most popular and widely used data model before relational data model
• Used to map many-to-many data relationships
Network Data Model
• Was developed to overcome limited scope of hierarchical model
• Original network model and language were presented in CODASYL through Data Base
Task Group (DBTG) → DBTG model
• 1971 →initial report describing a network database implementation was issued
• Revised reports were issued in 1978 and 1981
• Was the basis of one of the oldest database management system IDS (Integrated
Data System)
• 1960s → developed by Charles Bachman at General Electric
• 1963 → Electric Company began to market IDS
• "Bachman Diagram" was also named in the honor of Charles Bachman to represent network
databases
• Many network DBMSs exist even today
• IDMS (Integrated Database Management System) from Computer Associates
• Prime DBMS from Prime Computers
• DBMS-11 from DEC (Digital Equipment Corporation)
Network Data Model
+Conceptual Simplicity - System Complexity
+Capability to handle more - Operational Anomalies
relationship types - Absence of structural Independence
+Faster data access
+Data Independence
• Note: The E-R model, the semantic object model,
and the relational data model will be discussed in
the next chapters
• Details are given in PM Series book
For more details, refers to
PM Series
Database Management
by
CM Aslam & Aqsa Aslam
Publisher: Majeed Sons
22- Urdu Bazar, Lahore