lec-3 describing & storing data in database
TRANSCRIPT
-
7/30/2019 Lec-3 Describing & Storing Data in Database
1/15
DESCRIBING AND STORINGDATA IN A DATABASE
Lecture 3
-
7/30/2019 Lec-3 Describing & Storing Data in Database
2/15
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
-
7/30/2019 Lec-3 Describing & Storing Data in Database
3/15
Database Schema
Valid State
DBMS checks every state of the database
does it satisfy the structure and constraintsspecified in the schema?
Schema Diagram
for displaying database schema
schema construct: an object in the schema
no instance of records
-
7/30/2019 Lec-3 Describing & Storing Data in Database
4/15
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
-
7/30/2019 Lec-3 Describing & Storing Data in Database
5/15
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 holdon the database.
Schema Diagram: A diagrammatic display of (some aspects of ) a
database schema.
Database Instance: The actual data stored in a database at aparticular
moment in time. Also called database state ( or occurrence, snapshot)
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.
Each schema construt has its own current set of instances.
-
7/30/2019 Lec-3 Describing & Storing Data in Database
6/15
Figure 2.1 Schema diagram forUNIVERSITY database
schema construct
Known data:
name of record types, data items
-
7/30/2019 Lec-3 Describing & Storing Data in Database
7/15
Figure 1.2
UNIVERSITY Database
-
7/30/2019 Lec-3 Describing & Storing Data in Database
8/15
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
-
7/30/2019 Lec-3 Describing & Storing Data in Database
9/15
Levels of Abstraction
External
schema 1
External
schema 1
External
schema 1
Conceptual schema
Physical schema
Disk
-
7/30/2019 Lec-3 Describing & Storing Data in Database
10/15
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 orgroups of users
Each conceptual schema consist of collection of one or moreviews.
Example:
StdGrade(RegNo:Integer, Name:String,Sem:Integer, Grade:Char)
-
7/30/2019 Lec-3 Describing & Storing Data in Database
11/15
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)
-
7/30/2019 Lec-3 Describing & Storing Data in Database
12/15
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 schemaare stored on secondary storage devices such as disks and
tapes.
-
7/30/2019 Lec-3 Describing & Storing Data in Database
13/15
Program-Data Independence
The data independence is the ability tochange the schema at one level of a databasesystem with out changing the schema at a
higher level. Logical data Independence
capacity to change the conceptual schemawithout having to change the externalschema, is called as the logical dataindependence. With out changing theapplication programs, one can change thelogical schema.
http://www.doag.de/orafaq/glossary/faqgloss.htmhttp://www.doag.de/orafaq/glossary/faqgloss.htm -
7/30/2019 Lec-3 Describing & Storing Data in Database
14/15
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 modificationcan still retrieve the data with little
modification (relation name) and obtainthe same answer.
-
7/30/2019 Lec-3 Describing & Storing Data in Database
15/15
Physical data independenceCapacity to change the internal schema without
having to change the conceptual schema isknown as Physical data Independence.
There are occasions for changing the
internal structures for improvedperformance of the retrieval of data.
Any change introduced to the internal
schema or physical schema will not affectthe other schemas.