Unit 1 Part2
Unit 1 Part2
Data model
• Data model is collection of concepts that can be used to describe the structures of a
database.
• Provides the necessary means to achieve this abstraction. By structure of a database
Categories of data models
The Data Models describe the availability of services to an interfacing application as how to
access a data item when other relevant data items are known.
i) Low level or Physical data models
ii) High level or Conceptual data model
iii) Representational or Implementation Data model
i) Low level or Physical data models
They provide concepts about physical storage of data i.e. how to store data in a computer
hard disk. They specify about record formats, record ordering and access paths etc.
Low level data model details are generally meant for computer scientists, not for typical
end users.
This data models make search for a particular database in DBMS
Examples: Heaps, ISAM, VSAM, and Hash.
Foreign keys are used to identify relationships between tables.
ii) High level or Conceptual data model
These models are also referred as Logical data models.
They provide concepts for typical end users at high level i.e., that are independent of
physical storage.
Conceptual data model use concept such as entities, attributes and relationships.
Entity: It represents Real-Word object or concept or Real-thing. Such as employee or
project, that describe in the database.
Attribute: It represent the some properties of entity such as employee‘s salary or name.
iii) Representational or Implementation Data model
• This models are used most frequently in traditional commercial DBMSs. These include widely
used relational data model.
• These include widely used relational data model as well as the so-called legacy data models
the network and hierarchical models.
• Representational data models represent data by using record structures and hence are sometimes
called record-based data models.
• We can regard the object data model as an example of a new family of higher-level
implementation data models that are closer to conceptual data models.
Database Schema
• Database Schema:- The notation of the database representation or simply description of a
database is referred to as database schema.
• It is specified during database design and is not expected to change frequently.
• The data models have certain conventions for displaying schemas as diagrams. A displayed
schema is called a schema diagram.
• A schema diagram displays only some aspects of a schema, such as the names of record types
and data items, and some types of constraints.
DATABASE STATE:
A data in the database at a particular moment in time called database state or Instance or
snapshot.
It is also called the current set of occurrences or instances in the database.
In a given database state, each schema construct has its own current set of instances.
Example: STUDENT construct will contain the set of individual student entities (records) as
its instances.
When we define a new database, we specify its database schema only to the DBMS.
At this point, the corresponding database state is the empty state with no data.
We get the initial state of the database when the database is first populated or loaded with the
initial data.
After this, every time an update operation is applied to the database, we get another database
state.
At any point in time, the database has a current state.
The DBMS is partly responsible for ensuring that every state of the database is a valid state
that is, a state that satisfies the structure and constraints specified in the schema.
The schema is sometimes called the intension, and a database state is called an extension of the
schema.
Three-Schema Architecture
The goal of the three-schema architecture is to separate the user applications and the physical
database.
In this architecture, schemas can be defined at the following three levels:
a) The Internal schema at physical level (internal level)
b) Logical level at Conceptual schema (conceptual level)
c) The external schema at View level (External level)
a) The Internal schema at physical level (internal level):-
It is lowest level of data abstractions defining the physical storage structure of the database.
Which describes the physical storage structure of the database.
The internal schema uses a physical data model and describes the complete details of data
storage and access paths for the database.
b) Logical level at Conceptual schema (conceptual level):
It is next higher level of data abstraction which describes the structure of the whole
databasme for a community of users.
The conceptual schema hides the details of physical storage structures and concentrates on
describing entities, data types, relationships, user operations, and constraints.
It is a representational data model is used to describe the conceptual schema when a database
system is implemented.
This implementation conceptual schema is often based on a conceptual schema design in a high-
level data model.
c) The external schema at View level (External level)
It is highest level of abstraction defining only part of database.
It includes a number of external schemas or user views.
Each external schema describes the part of the database that particular user group is interested in
and hides the rest of the database from that user group.
This level of abstraction simplifies end user‘s interaction with database system.
As in the previous level, each external schema is typically implemented using a representational
data model, possibly based on an external schema design in a high-level data model.
Mappings
DBMS must transform a request specified on an external schema into a request against the
conceptual schema, and then into a request on the internal schema for processing over the
stored database.
If the request is a database retrieval, the data extracted from the stored database must be
reformatted to match the user’s external view.
The processes of transforming requests and results between levels are called mappings.
These mappings may be time-consuming, so some DBMSs especially those that are meant to
support small databases do not support external views.
Even in such systems, however, a certain amount of mapping is necessary to transform
requests between the conceptual and internal levels.
Data Independence
It is defined as the capacity to change the schema at one level of a database system
without having to change the schema at the next higher level.
It is categorized into 2 types as follows,
1) Logical Data Independence
2) Physical Data Independence
1) Logical Data Independence:
It is the capacity to change the conceptual schema without having to change
external schemas or application programs.
We may change the conceptual schema to expand the database (by adding a record type or data
item), to change constraints, or to reduce the database (by removing a record type or data item).
Consider the example of student database. The schema constructs for student entity may
further modified by appending 2 or more attributes fields such as PERCENTAGE and
GRADE.
For such modifications at conceptual schema level, the logical data independence
accommodates these changes.
2) Physical Data Independence:
It is defined as the capacity to change internal schema without having to change
the conceptual schema.
For example: Physical changes to database or internal schema may include changing
access technique to improve the performance of database retrieval.
Physical Data independence permits tuning of the physical database for performance
reason while allowing respective application programs to run as if no change had taken
place.
DBMS Languages
DDL(Data Definition Language )
DML(Data Manipulation Language )
SDL(Storage Definition Language )
VDL(View Definition Language)
TCL (Transaction Control Language)
DCL (Data Control Language)
Data Definition Language (DDL)
It is used by the DBA and by database designers to define both conceptual and
internal schemas and any mappings between the two.
The DBMS will have a DDL compiler whose function is to process DDL statements in
order to identify descriptions of the schema constructs and to store the schema description
in the DBMS catalog.
CREATE - to create objects in the database
ALTER - alters the structure of the database
DROP - delete objects from the database
TRUNCATE - remove all records from a table, including all spaces allocated for the records
are removed
COMMENT - add comments to the data dictionary
RENAME - rename an object
Data manipulation language (DML)
Once the database schemas are compiled and the database is populated with data, users
must have some means to manipulate the database.
Typical manipulations include retrieval, insertion and deletion of data. The DBMS provides
these set of operations or languages called Data manipulation language (DML).
These Statements are used for managing data within schema objects.
SELECT - Retrieve data from the database
INSERT - Insert data into a table
UPDATE - Updates existing data within a table
DELETE - deletes all records from a table
View Definition Language (VDL)
It is used to specify user views and their mappings to the conceptual schema,
But in most DBMSs the DDL is used to define both conceptual and external schemas.
In relational DBMSs, SQL is used in the role of VDL to define user or application views
as results of predefined queries
Storage Definition Language (SDL)
The DDL is used to specify the conceptual schema only. And SDL is used to specify the
internal schema.
The mappings between the two schemas may be specified in either one of these languages
(DDL, SDL).
Instead, the internal schema is specified by a combination of functions, parameters,
and specifications related to storage.
These permit the DBA staff to control indexing choices and mapping of data to storage.
Transaction Control Language (TCL)
Statements are used to manage the changes made by DML statements. It allows statements to
be grouped together into logical transactions.
Some examples: - COMMIT - Save the work permanently
SAVEPOINT - identify a point in a transaction to which you can later roll back
ROLLBACK - restore database to original since the last COMMIT.
Data Control Language (DCL)
It used to control access to data stored in a database (Authorization). In particular, it is a
component of Structured Query Language (SQL).
GRANT - gives user's access privileges to database
REVOKE - withdraw access privileges given with the GRANT command
DBMS Interfaces
User-friendly interfaces provided by a DBMS may include the following:
1. Menu-Based Interfaces for Web Clients or Browsing
2. Form Based Interlaces
3. Graphical User Interfaces
4. Natural Language Interfaces
5. Speech Input and Output
6. Interfaces for Parametric Users
7. Interfaces for the DBA.
1. Menu-Based Interfaces for Web Clients or Browsing.
These interfaces present the user with lists of options (called menus) that lead the user
through the formulation of a request.
Menus do away with the need to memorize the specific commands and syntax of a query
language; rather, the query is composed step-by-step by picking options from a menu that is
displayed by the system.
Pull-down menus are a very popular technique in Web-based user interfaces.
They are also often used in browsing interfaces, which allow a user to look through the
contents of a database in an exploratory and unstructured manner.
2. Form Based Interlaces
A forms based interface displays a form to each user. Users can fill out all of the form
entries to insert new data, in which case the DBMS will retrieve matching data for the
remaining entries.
Forms are usually designed and programmed for native users as interfaces to canned
transactions.
Many DBMSs have forms specification languages, which are special languages that
help programmers, specify such forms.
SQL*Forms is a form-based language that specifies queries using a form designed in
conjunction with the relational database schema.
3. Graphical User Interfaces
A GUI typically displays a schema to the user in diagrammatic form. The user then can
specify a query by manipulating the diagram.
In many cases, GUIs utilize both menus and forms. Most GUIs use a pointing device,
such as a mouse, to pick certain parts of the displayed schema diagram.
4. Natural Language Interfaces
These interfaces accept requests written in English or some other language and attempt
to understand them.
A natural language inter-face usually has its own schema, which is similar to the database
conceptual schema, as well as a dictionary of important words.
The natural language interface refers to the words in its schema, as well as to the set of
standard words in its dictionary, to interpret the request.
The capabilities of natural language interfaces have not advanced rapidly.
5. Speech Input and Output
The speech input is detected using library words and used to set-up parameters that separate
the queries. Ex: Telephone Directories.
Limited use of speech as an input query and speech as an answer to a question or result of a
request is becoming commonplace.
Applications with limited vocabularies such as inquiries for telephone directory, flight
arrival/departure, and bank account information are allowing speech for input and output to
enable ordinary folks to access this information.
6. Interfaces for Parametric Users
Parametric users, such as bank tellers, often have a small set of operations that they
must perform repeatedly.
For example, a teller is able to use single function keys to invoke routine and repetitive
transactions such as account deposits or withdrawals, or balance inquiries.
Systems analysts and programmers design and implement a special interface for each
known class of native user.
Interfaces for the DBA
It is framework includes powerful commands utilized by the DBA.
These contain instructions for generating accounts, setting system frameworks, allocating
account permission, modifying a schema, and rearranging the storage mechanism of the
database.