Вы находитесь на странице: 1из 15

DESCRIBING AND STORING DATA IN A DATABASE

Lecture 3

DB Schema vs. DB State


Database Schema (intension)
description of the database is specified during database design

Database State (extension of the schema)


current state of the database actual data instances (occurrences) in a DB changes over time by update initially, a database is empty state with no data then, populate (load) the database with data

Database Schema
Valid State
DBMS checks every state of the database does it satisfy the structure and constraints specified in the schema?

Schema Diagram
for displaying database schema schema construct: an object in the schema no instance of records

Database Schema (cont)


Meta-data
descriptions of the schema constructs and constraints stored in the database catalog

Schema Evolution
Schema change prompted by the change of application requirements

2.1.2 Schemas, Instances and Database State


Database Schema (meta-data): The description of a database. Includes descriptions of the database structure and the constraints that should hold on the database. Schema Diagram: A diagrammatic display of (some aspects of ) a database schema. Database Instance: The actual data stored in a database at a particular moment in time. Also called database state ( or occurrence, snapshot)
Each schema construt has its own current set of instances.

The database schema changes very infrequently. The database state changes every time the database is updated. Schema is also called intension, whereas state is called extension.

Figure 2.1

Schema diagram for UNIVERSITY database

schema construct

Known data: name of record types, data items

Figure 1.2 UNIVERSITY Database

Database schema (e.g. relational):


Names and types of attributes Addresses Indexing Statistics Authorization rules to access data etc. Data independence: separation of the physical and logical data

Particularly important for distributed systems


The mapping between them is provided by the schema

Levels of Abstraction
External schema 1 External schema 1 External schema 1

Conceptual schema

Physical schema

Disk

External Schema
Describes several views of the database based on the database model. Several external schemas are possible for a single database. Each view is based upon the user requirements. Data access to be customized at a level of individual users or groups of users Each conceptual schema consist of collection of one or more views.

Example: StdGrade(RegNo:Integer, Name:String, Sem:Integer, Grade:Char)

Conceptual Schema
Describes the stored data in terms of the data model of the DBMS. This leads to conceptual database design. There is only one Conceptual schema of Database. DBMS maps from conceptual schema to physical schema Example: Student(RegNo:Integer, Name:String, Sem:Integer, Branch:String) Faculty(Fid:Integer, FName:String, Salary:Float) Course(CourseNo:Integer, CName:String, Credit:Integere, Dept:String) Section(SecId:Integer, CourseNo:Integer, Sem:Integer, Year:Integer, Instructor:String) GradeReport(RegNo:Integer, SecId:Integer, Grade:Char)

Physical Schema
Describes the actual storage details of the relations described in conceptual schema.
This leads to the physical database design. Physical schema specifies additional storage devices Describes how the relations described in conceptual schema are stored on secondary storage devices such as disks and tapes.

Program-Data Independence
The data independence is the ability to change the schema at one level of a database system with out changing the schema at a higher level. Logical data Independence capacity to change the conceptual schema without having to change the external schema, is called as the logical data independence. With out changing the application programs, one can change the logical schema.

Example

Suppose the Faculty relation is modified as: Faculty_Public(Fid:Integer, FName:String, Office:Integer) Faculty_Private(Fid:Integer, Salary:Float) Any view designed before this modification can still retrieve the data with little modification (relation name) and obtain the same answer.

Physical data independence


Capacity to change the internal schema without having to change the conceptual schema is known as Physical data Independence.

There are occasions for changing the internal structures for improved performance of the retrieval of data. Any change introduced to the internal schema or physical schema will not affect the other schemas.

Вам также может понравиться