0% found this document useful (0 votes)
20 views66 pages

1 - 4 - Schema Arch

The document outlines the architecture of databases, focusing on the schema, which is the overall design and structure of the database, and the differences between schema and instance. It describes various types of database architectures, including 1-Tier, 2-Tier, and 3-Tier architectures, as well as the three-schema architecture that separates user applications from the physical database. Additionally, it covers data independence and the types of database languages used for defining, manipulating, and controlling data.

Uploaded by

kashif r
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views66 pages

1 - 4 - Schema Arch

The document outlines the architecture of databases, focusing on the schema, which is the overall design and structure of the database, and the differences between schema and instance. It describes various types of database architectures, including 1-Tier, 2-Tier, and 3-Tier architectures, as well as the three-schema architecture that separates user applications from the physical database. Additionally, it covers data independence and the types of database languages used for defining, manipulating, and controlling data.

Uploaded by

kashif r
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 66

Database

architecture
Schema
 The overall design of a database is called schema.
 A database schema is the skeleton structure of the
database.
 It represents the logical view of the entire database.
 A schema contains schema objects like table, foreign
key, primary key, views, columns, data types, stored
procedure, etc.
 Schema will not be changed frequently.
 It does not show the data in the database.
Contd…
 A database schema can be represented by using the visual
diagram.
 That diagram shows the database objects and relationship with
each other.
 A database schema is designed by the database designers to help
programmers whose software will interact with the database.
 The process of database creation is called data modeling.
 A schema diagram can display only some aspects of a schema like
the name of record type, data type, and constraints. Other
aspects can't be specified through the schema diagram.
Schema

 The schema is pictorially represented as −


Contd…
 Generally the Database Management System (DBMS) assists one
physical schema, one logical schema and several sub or external
schemas.

 Database schema refers to the format and layout of the database


in which the data will be stored.

 It is the one thing that remains the same throughout unless


otherwise modified.

 It defines the structure of what type of data and how it will be


stored.
Example
 A database schema for a person will have fields for name, email,
phone and address as shown below −

 Person

Name Email Phone no


Types of Schema

The different types of schemas are as follows −

Physical schema −

 It is a database design at the physical level.

 It is hidden below the logical schema and can be changed easily


without affecting the application programs.
Contd…

Logical schema −

 It is a database design at the logical level.

 Programmers construct applications using logical schema.


Contd…

External −

 It is schema at view level.

 It is the highest level of a schema which defines the views for end
users.
Instance

 The data which is stored in the database at a particular


moment of time is called an instance of the database.

 Instance or extension or database state is a collection of


information that stored in a database at a particular
moment is called an instance of the database.

 The Database instance refers to the information stored in


the database at a given point of time.

 Thus, it is a dynamic value which keeps on changing.


Instance: Example
 A database instance for the Person database can be
(User1,email.com,11345679) So the person construct
will contain their individual entities in the attributes
called as instance.
 This is shown below −

Name Email Phone no


BOB [email protected] 2343435
JAY [email protected] 5345464
PRIYA [email protected] 2342342
Differences between schema and instance
Database Schema Database Instance

It is the definition of the database or it is It is a snapshot of a database at a specific


defined as the description of the database. moment.

It rarely changes. It changes frequently.

Example” We take two tables emp table and At a moment, what is the value of the
dept table. Emp Id Dept database schema is called instance. At t=8
Name
A.M Empid name salary did
Dept_id
Salary dname 1 A 5000 d1
dept 2 B 2000 d2
Emp and dept both called
as schemas It gives database definition. Empid 1 and 2 are called as Instance 1

This corresponds to the variable declaration The value of the variable in a program at a
of a programming language. point in time corresponds to an instance of
the database schema.
Architecture of DBMS
 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 their request done.
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.
 No network connection is required to perform action on
database.
 The 1-Tier architecture is used for development of the local
application, where programmers can directly communicate
with the database for the quick response.
Contd…
 The 1-Tier architecture is used-

 where data does not change frequently and no multiple


user are accessing the system.
 for development of the local application, where
programmers can directly communicate with the
database for the quick response.
1-Tier Architecture
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.
 An API like ODBC, JDBC are used by client program to access
database.
 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 server side.
Contd…
 It is used inside any organization, where multiple
clients are accessing the database server
directly.

 Example Railway Reservation System from


counter where clerk access the railway server
directly.
Contd…
 Advantage-
 Direct and faster communication.
 Maintenance and understanding easier.
 Compatible with existing system.

 Disadvantage-
 Scalability
i.e. it gives poor performance where there are
large number of users.
 Less secure as client can access the server directly.
2-Tier Architecture
3-Tier Architecture
 The 3-Tier architecture contains another layer of
Application Server 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 and then the query processing and
transaction management takes place.
 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.
Contd…
 The 3-Tier architecture is used in case of large web
application.
 It is the most popular DBMS architecture.
 Advantages-
 Enhanced scalability due to distributed deployment of
application server. Individual connection need not be made
between client and server.
 Data Integrity is maintained. Since there is a middle layer
between client and server, data corruption can be
avoided/removed.
 Security is improved. Reduce access to unauthorized data.
Contd…
 Disadvantages-

 Increasedcomplexity of implementation and


communication.
 Itbecomes difficult for this sort of interaction to
take place due to presence of middle layer.
3-Tier Architecture
Three Schema Architecture

 Thethree schema architecture is also called ANSI/SPARC


architecture or three-level architecture.
 Thisframework is used to describe the structure of a
specific database system.
 The three schema architecture is also used to separate
the user applications and physical database.
 Thethree schema architecture contains three-levels. It
breaks the database down into three different categories.
Three schema Architecture

• It shows the DBMS architecture.


• Mapping is used to transform the request and response
between various database levels of architecture.
• Mapping is not good for small DBMS because it takes
more time.
• In External / Conceptual mapping, it is necessary to
transform the request from external level to conceptual
schema.
• In Conceptual / Internal mapping, DBMS transform the
request from the conceptual to internal level.
Contd…

The three-schema architecture


Objectives of Three schema Architecture
 The main objective of three level architecture is to
enable multiple users to access the same data with a
personalized view while storing the underlying data only
once.
 Thus it separates the user's view from the physical
structure of the database. This separation is desirable for
the following reasons:
 Different users need different views of the same data.
 Theapproach in which a particular user needs to see the
data may change over time.
Contd…
 The users of the database should not worry about the
physical implementation and internal workings of the
database such as data compression and encryption
techniques, hashing, optimization of the internal
structures etc.
 All users should be able to access the same data
according to their requirements.
 DBA should be able to change the conceptual structure
of the database without affecting the user's
 Internal structure of the database should be
unaffected by changes to physical aspects of the
storage.
Internal Level

 The internal level has an internal schema which


describes the physical storage structure of the
database.
 The internal schema is also known as a physical
schema.
 It uses the physical data model. It is used to
define that how the data will be stored in a
block.
 The physical level is used to describe complex
low-level data structures in detail.
Contd…

Internal view
Conceptual Level
 The conceptual schema describes the design of a
database at the conceptual level. Conceptual level is
also known as logical level.
 The conceptual schema describes the structure of the
whole database.
 The conceptual level describes what data are to be
stored in the database and also describes what
relationship exists among those data.
 In the conceptual level, internal details such as an
implementation of the data structure are hidden.
 Programmers and database administrators work at this
level.
Contd…

Global view
3. External Level

 At the external level, a database contains several schemas that


sometimes called as subschema. The subschema is used to describe
the different view of the database.
 An external schema is also known as view schema.
 Each view schema describes the database part that a particular user
group is interested and hides the remaining database from that user
group.
 The view schema describes the end user interaction with database
systems.
Mapping between Views
 The three levels of DBMS architecture don't exist
independently of each other.

 There must be correspondence between the three


levels i.e. how they actually correspond with each
other.

 DBMS is responsible for correspondence between the


three types of schema.

 This correspondence is called Mapping.


Contd…
There are basically two types of mapping in the
database architecture:

1. Conceptual/ Internal Mapping

1. External / Conceptual Mapping


Conceptual/ Internal Mapping:

 The Conceptual/ Internal Mapping lies between the


conceptual level and the internal level.

 Itsrole is to define the correspondence between the


records and fields of the conceptual level and files and
data structures of the internal level.
External/ Conceptual Mapping:

 The external/Conceptual Mapping lies between the


external level and the Conceptual level.

 Its role is to define the correspondence between a


particular external and the conceptual view.
Data Independence

 Data independence can be explained using the three-schema


architecture.
 Data independence refers to the characteristics of being
able to modify the schema at one level of the database
system without altering the schema at the next higher level.

 There are two types of data independence:


1. Logical Data Independence
2. Physical Data Independence
1. Logical Data Independence

 Logical data independence refers to characteristics of


being able to change the conceptual schema without
having to change the external schema.
 Logical data independence is used to separate the
external level from the conceptual view.
 If we do any changes in the conceptual view of the
data, then the user view of the data would not be
affected.
 Logical data independence occurs at the user interface
level.
2. Physical Data Independence
 Physical data independence can be defined as the
capacity to change the internal schema without having
to change the conceptual schema.
 If we do any changes in the storage size of the database
system server, then the Conceptual structure of the
database will not be affected.
 Physical data independence is used to separate
conceptual levels from the internal levels.
 Physical data independence occurs at the logical
interface level.
Data Independence
Database Languages in DBMS

 A DBMS has appropriate languages and interfaces to


express database queries and updates.

 Database languages can be used to read, store and


update the data in the database.
Types of Database Languages
Contd…

 1. Data Definition Language (DDL)

 2. Data Manipulation Language (DML)

 3. Data Control Language (DCL)

 4. Transaction Control Language (TCL)


1. Data Definition Language (DDL)
 DDL stands for Data Definition Language. It is used to
define database structure or pattern.
 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.
 Data definition language is used to store the
information of metadata like the number of tables and
schemas, their names, indexes, columns in each table,
constraints, etc.
Contd…
Some tasks that come under DDL:

 Create: It is used to create objects in the database.


 Alter: It is used to alter the structure of the database.
 Drop: It is used to delete objects from the database.
 Truncate: It is used to remove all records from a table.
 Rename: It is used to rename an object.
 Comment: It is used to comment on the data
dictionary.

These commands are used to update the database .


2. Data Manipulation Language (DML)
 DML stands for Data Manipulation Language. It is used for
accessing and manipulating data in a database. It handles user
requests.

Some tasks that come under DML:

• Select: It is used to retrieve data from a database.


• Insert: It is used to insert data into a table.
• Update: It is used to update existing data within a table.
• Delete: It is used to delete all records from a table.
Contd…
• Merge: It performs operation like- insert or update
operations.
• Call: It is used to call a structured query language or a Java
subprogram.
• Explain Plan: It has the parameter of explaining data.
• Lock Table: It controls concurrency.

NOTE : Query Language: Query Language is the part of the


DML used for retrieving information. The term query language
and data manipulation language are frequently used
interchangeably.
3. Data Control Language (DCL)
 DCL stands for Data Control Language. It is used to
retrieve the stored or saved data.
 The DCL execution is transactional. It also has rollback
parameters.

(But in Oracle database, the execution of data control


language does not have the feature of rolling back.)
Contd…
Some tasks that come under DCL:

 Grant: It is used to give user access privileges to a


database.
 Revoke: It is used to take back permissions from the user.

 Some of the following operations which have the


authorization of Revoke are:

 CONNECT, INSERT, USAGE, EXECUTE, DELETE, UPDATE and


SELECT.
4. Transaction Control Language (TCL)
 TCL is used to run the changes made by the DML
statement.
 TCL can be grouped into a logical transaction.

 Some tasks that come under TCL:

 Commit: It is used to save the transaction on the


database.
 Rollback: It is used to restore the database to original
since the last Commit.
Interfaces in DBMS
 A database management system (DBMS) interface is a user
interface that allows for the ability to input queries to a
database without using the query language itself.
 User-friendly interfaces provided by DBMS may include
the following:
1. Menu-Based Interfaces for Web Clients or Browsing
2. Forms-Based Interfaces
3. Graphical User Interface
4. Natural language Interfaces
5. Speech Input and Output
6. Interfaces for 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
formation of a request.
 Basic advantage of using menus is that they removes
the tension of remembering specific commands and
syntax of any query language.
 The query is basically composed step by step by
collecting or picking options from a menu that is
shown by the system.
Contd…

 Pull-down menus are a very popular technique in Web


based interfaces.
 They are also often used in browsing interface which
allow a user to look through the contents of a
database in an exploratory and unstructured manner.
2. Forms-Based Interfaces

 A forms-based interface displays a form to each user.


 Users can fill out all of the form entries to insert new
data, or they can fill out only certain entries, in which
case the DBMS will redeem same type of data for other
remaining entries.
 These types of forms are usually designed or created
and programmed for the users that have no expertise
in operating system.
Contd…
 A forms-based interface displays a form to each user.
 Users can fill out all of the form entries to insert new
data, or they can fill out only certain entries, in
which case the DBMS will redeem same type of data
for other remaining entries.
 These types of forms are usually designed or created
and programmed for the users that have no expertise
in operating system.
3. Graphical User Interface

 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 mouse, to pick
a certain part of the displayed schema diagram.
4. Natural language Interfaces

 These interfaces accept request written in English or


some other language and attempt to understand
them.
 A Natural language interface 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
a dictionary to interpret the request.
Contd…
 If the interpretation is successful, the interface
generates a high-level query corresponding to the
natural language and submits it to the DBMS for
processing, otherwise a dialogue is started with the
user to clarify any provided condition or request.
 The main disadvantage with this is that the
capabilities of this type of interfaces are not that
much advance.
5. Speech Input and Output
 There is limited use of speech be it for a query or an
answer to a question or being a result of a request it is
becoming commonplace.

 Applications with limited vocabularies such as inquiries


for telephone directory, flight arrival/departure, and
bank account information are allowed speech for input
and output to enable ordinary folks to access this
information.
Contd…

 The Speech input is detected using predefined words


and used to set up the parameters that are supplied
to the queries.

 For output, a similar conversion from text or numbers


into speech takes place.
6. Interfaces for DBA

 Most database system contains privileged commands


that can be used only by the DBA’s staff.

 These include commands for creating accounts, setting


system parameters, granting account authorization,
changing a schema, reorganizing the storage structures
of a databases.
That’s All
Queries???

You might also like