Sie sind auf Seite 1von 54

Schemas, Subschema and Instances

Schema:The plan (or formulation ) of the database


is known as schema.
Schema gives the names of the entities
and attributes.
Schema specifies the relationship among
them.

It is a framework into which the values of


the data items (or fields) are fitted.
The plans or the format of
remains the same.

schema

But the values fitted into this format


changes from instance to instance.
The following example specifies the
context of the schema of M/s ABC, a
manufacturing company.

Product
Prod-id

Prod-desc Unit-cost

Customer
Cust- Cust- Cust- Cust- Custid
name stree city
bal
t
Sales
Cust-id Prod-id Prodcity

Prodprice

Schema diagram for


sales record

The schema diagram displays the structure


of each record type but not the actual
instances of records.
Each object in the schema, for example,
PRODUCT, CUSTOMER, SALES are called
schema construct.

Schema name is SALES-RECORD


type PRODUCT=record
PROD-ID:String;
PROD-DESC:String;
UNIT-COST:integer;
end
type CUSTOMER=record
CUST-ID:integer;
CUST-NAME:String;
CUST-STREET=String;
CUST-CITY=String;
CUST-BAL=integer;
end
type SALES=record
CUST-ID=integer;
PROD-ID=String;
PROD-QTY=integer;
PROD-PRICE=integer;
end

Attributes (or
fields, or data
items)

Attributes (or
fields, or data
items)

Attributes (or
fields, or data
items)

Schema defined using database


language

A database system can have several


schemas partitioned according to the levels
of abstraction.
In general Schema can be categorised in
two parts.
1) Logical Schema
2) Physical Schema

The logical schema is concerned with


exploiting the data structures offered by a
DBMS in order to make the schema
understandable to the computer.
The physical schema deals with the
manner in which the conceptual database
shall get represented in the computer as a
stored database.

The logical schema is the most important


as programs use it to construct
applications.
The physical schema is hidden beneath the
logical schema and can usually be changed
easily without affecting application
programs.
DBMSs provide DDL and DSDL in order to
make the specification of both the physical
and logical schema easy for the DBA.

Subschema:It is a subset of the schema and inherits


the same property that a schema has.
The plan(or schema) for a view is often
called subschema.
Subschema refers to an application
programmers (users) view of the data item
types and record types, which he or she
uses.

Subschema gives the users a window


through which he or she can view only
that part of the database, which is of
interest to him.
Different application programs can have
different view of data.
Individual application programs can
change their respective subschema
without effecting subschema views of
others.

The
DBMS
software
derives
the
subschema data requested by application
programs from schema data.
The
database
administrator
(DBA)
ensures that the subschema requested by
application programs is derivable from
schema.
The change in physical organisation of
data, application programs for subschema
need not be changed or modified.

Subschemas also act as a unit for enforcing


controlled access to the database.
Subschema can be made for controlling
concurrent operations on the database.
Subschema definition language (SDL) is
used to specify a subschema in the DBMS.
The Subschema is sometimes referred to as
an LVIEW or Logical view.
Many different Subschemas can be derived
from one schema.

INSTANCES:When the schema framework is filled


in the data item values or the contents
of the database at any point of time (or
current contents), it is referred to as an
instance of the database.
The term instance is also called as
state of the database or snapshot.

PRODUCT
PRODUCT-ID

PRODUCT-DESC

UNIT-COST

A12345

STEEL ALMIRAH

4000

B23412

DRYER

4500

B44332

FREEZE

6000

A98765

STEEL TABLE

3500

A29834

STEEL CHAIR

4800

C11008

IRON MOULDING

5100

Instance of the PRODUCT


relation

CUSTOMER
CUSTID

CUSTNAME

1001

CUSTSTREET

CUSTCITY

CUSTBAL

Waterhous Box 41,


e ltd.
Mumbai

Mumbai

65000.
00

1000

KLY
System

Chicago

40000.
00

1005

Megapoint C-12, Pataya,


s
Goa

Goa

84000.
00

1010

Concept
Shapers

32, Main
Road, Ranchi

Mumbai

10500.
00

1006

Trinity
Agencies

P.O.Box 266,
Tokyo

Delhi

11200.
00

41, 1st street,


Chicago

Instance of the CUSTOMER

SALES
CUST-ID

PROD-ID

QTY

UNITPRICE

1001

A12345

100

6,700

1000

B23412

250

4,000

1010

B44332

120

14,000

1005

A98765

110

5,500

1001

A29834

300

12,999

Instance of the SALES


relation
At any point of time, the current state of the
database is called the instance.

THREE-LEVEL DATA BASE


ARCHITECTURE
The
Database
Task
Group
(DBTG)
appointed by the Conference on Data
systems
and
Languages
(CODASYL),
produced a proposal for general architecture
for database systems.
The DBTG proposed a two-tier architecture
with a system view called the schema and
users views called subschemas.

In 1975, ANSI-SPARC (American National


Standards Institute- Standard Planning and
Requirements Committee) produced a
three-tier architecture with a system
catalog.
The three-tier architecture consists of the
following three levels:
1) Internal level
2) Conceptual level
3) External level

External
level
(Defined by
user or
application
program)

External Schema
User
view 1

Conceptual level
(Defined by DBA)

Internal Level
(Defined by
DBA)

User
view 1

User
view 1

*******

Conceptual Schema

Internal Schema

Physical
Database
Physical
Level

File

file
file

file

file

User
view 1

The view at each of the levels is described


by a scheme or schema.
The term view, scheme and schema are
used interchangeably.
The DDL is used to define the Conceptual
and external schemas.
The SQL are used to describe the aspects
of the physical (or internal schema).
Information
about
the
internal,
conceptual and external schemas is stored
in the system catalog.

The following example specifies three levels


corresponding to three views (namely
internal, conceptual and external views).
Custome
r
Cust-id

Custname

Custstreet

Cust-city

Type CUSTOMER=record
CUST-ID=integer;
CUST-NAME=string;
Integrated record
CUST-STREET=string;
definition of CUSTOMER
record
CUST-CITY=string;
CUST-BAL=integer;
end

Cust-bal

The lowest level of abstraction of data


contains a description of the actual method
of storing data and is called the internal
view.
STORED-CUST record length 74
CUST-ID:4 decimal offset 0 unique
CUST-NAME:string length 20 offset 4
CUST-STREET:string length 40 offset 24
CUST-CITY:string length 10 offset 64
CUST-BAL:8, 2 dec offset 74
AT the internal or physical level, customers are represented by
by a stored record type called STORED-CUST, which is 74 chracters
(or bytes) long. It contains five fields or data items corresponding
to five properties of customers.

The second level of abstraction is the


conceptual or global view.
CUSTOMER
CUST-ID:integer (4)
CUST-NAME:string (20)
CUST-STREET:string (40)
CUST-CITY:string (10)
CUST-BAL:integer (8)

At
the conceptual or global level, the database contains
information concerning an entity type called CUSTOMER. Each
individual customer has a CUST-ID (4 digits), CUST-NAME(20
characters), CUST-STREET(40 Characters) and CUST-BAL(8 digits).

The third level is the highest level of


abstraction seen by user or application
program and is called the external view or
user view.
The conceptual view is the sum total of user
view or external view of data.
CUSTCUST-CITY
NAME
USERS VIEW
#1

CUSTID

CUSTNAME

CUST-BAL

USERS VIEW
#2

The user view or logical or external schema of the database in


which one view contains two fields or data items and other view
contains three fields or data items .There

is only one
conceptual schema and one internal

Internal Level:It is the physical representation of the


database on the computer and this view
is found at the lowest level of
abstraction of database.
The level indicates how the data will
be stored in the database and describes
the data structures, file structures and
access methods to be used by the
database.
It describes the way the DBMS and

Internal level is concerned with the


following activities:
1) Storage space allocation for data and
storage
2) Record descriptions for storage with
stored sizes for data items.
3) Record placement
4) Data compression and data
encryption techniques.

The process arriving at a good internal (or


physical) schema is called physical
database design.
The internal schema is written using SQL or
internal data definition language
(internal DDL).

Conceptual Level:It is the middle level in the three-tier


architecture.
At this level of database abstraction, all
the database entities and relationships
among them are included.
It contains the logical structure of the
entire database as seen by the DBA.

It is complete view of the data


requirements of the organisation that is
independent of any storage considerations.
The
conceptual
conceptual view.

schema

defines

It is also called the logical schema.


There is only one conceptual schema per
database.

Conceptual level is concerned with the


following activities:1) All entities, their attributes and their
relationships.
2) Constraint on the data
3) Semantic information about the
data.

4) Checks to retain data consistency


and integrity.
5) Security information.

External level:It is the users view of the database.


It is the highest level of data abstraction.
Only those portions of the database of
concern to a user or application program
are included.
In external level, the different views may
have different representations of the
same data.

Advantages of Three-tier Architecture:The main objective of the three-tier


database architecture is to isolate each
users view of the database from the way
the database is physically stored or
represented.
1) Each user is able access same data
but have a different customized view of the
data as per their own needs.

2) The user is not concerned about the physical


data storage details.
3) The internal structure of the database is
unaffected by changes to the physical
storage organisation, such as changeover to
a new storage device.
4) The DBA is able to change the database
structures without affecting the users view.
5) The DBA is able to change the conceptual
structure of the database without affecting all
users.

Characteristics of Three-tier Architecture:The following table shows degree


abstraction, characteristics and type
DBMS used for the three levels.

of
of

Abstraction
Level

Physical
level

Internal Conceptu Externa


level
al level
l Level

Low

Medium

Hardware
and
software
dependent

Hardwar H/w and


e and
s/w
s/w
dependent
depende
nt

H/w and
S/w
depende
nt

Hierarchical
DBMS

Attention
required
about
physicallevel details

Attentio
n
required
about
physical
level
detail

Attention
required
about
physical
level
detail

Network
DBMS

Attention
required
about
physical
level details

Features
Degrees of
Abstraction

Deg
ree
of
kno
wle
dge
req
uir
ed
By
dat
aba
se

,,

High

Medium

Attention
required
about
physicallev el
detail

,,

,,

DATA INDEPENDENCE
It is a major objective of implementing
DBMS in an organisation.
It is the characteristics of a database
system to change the database schema at
one level without having to change the
schema at the next higher level.
1) Physical Data Independence
2) Logical Data Independence

Physical Data Independence:Immunity of the conceptual (or


external) schemas to changes in the internal
schema is referred to as physical data
independence.
Logical Data Independence:Immunity of the external schemas (or
application programs) to changes in the
conceptual schema is referred to as logical
data independence.

MAPPINGS:The process of transforming requests


and results between the three levels are
called mappings.
The DBMS is responsible for this
mapping between internal, conceptual, and
external schemas.

The Three-tier architecture model provides


the following two-stage mappings.
1) Conceptual/Internal mapping
2) External/Conceptual mapping

The conceptual Schema is related to the internal


schema through conceptual/internal mapping.
The conceptual/internal mapping defines the
correspondence between the conceptual view
and stored database.
It also allows any differences in entity names,
attribute names, attribute orders, data types and
so on, to be resolved.
Any change in the structure of the stored
database, the conceptual/internal mapping is also
changed accordingly by the structure of the DBA.

The external Schema is related to the


conceptual schema by the external/conceptual
mapping.
The external/conceptual mapping defines the
correspondence between a particular external
view and the conceptual view.
It gives the correspondence among the records
and relationships of the external and
conceptual views .

There could be one mapping


conceptual and internal levels

between

There are several mappings


external and conceptual levels.

between

DATA MODELS:A model is an abstraction process .


A data model also called database model
is a mechanism that provides this abstraction
for database application.
It represents the organisation itself.

A data model is a collection of mathematically


well-defined concepts that help an enterprise
to consider and express the static and
dynamic
properties
of
data
intensive
applications.
It consists of the following
1)
Static properties
attributes, relationships.

for

ex;

objects,

2) Dynamic properties for ex; operations or


rules defining new database states.

Data Models can be broadly classified into the


following three categories:
1) Record based data models.
2) Object-based data models.
3) Physical data models.

Record Based Data Models:They are used to specify the overall


logical structures of the database.
In this model the database consists of a
number of fixed-format records possibly of
different types.

There are three record based data models


1) Hierarchical data model
2) Network data model
3) Relational data model

Object Based Data Models:They are used to describe data and its
relationships.
It uses concepts such as entities, attributes
and relationships.
It has flexible data structuring capabilities.
Data integrity constraints can be explicitly
specified.

The following are the common types of


Object-based data models:1) Entity-Relationship model.
2) Semantic Model.
3) Functional model.
4) Object-oriented model.

Physical Data Models:They are used for a higher-level


description of storage structure and access
mechanism.
They describe how data is stored in the
computer.
It is possible to implement the database at
system level using physical data models.

The most common physical models are:1) Unifying model.


2) Frame memory model.

Hierarchical Data Models:The model is represented by an upsidedown tree.


The following figure shows the model

Level0 : Root Parent


(node)

Level1: Root Children


(Segments)

Level2: Segments
(level-1 children)

Das könnte Ihnen auch gefallen