Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Database Schema: The description of a database which is specified during database design and is not expected to change frequently. 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. Schema Construct: A component of the schema or an object within the schema, e.g., STUDENT, COURSE.
Physical schema: database design at the physical level Logical schema: database design at the logical level
Database Instance: The actual data stored in a database at a particular moment in time. Also called database state (or occurrence or snapshot).
The goal of the three-schema architecture is to separate the user applications and the physical database. The schemas can be divided into three levels: internal level has an internal schema, which describes the physical storage structure of the database
Conceptual level has a conceptual schema hides the details of physical storage structures and concentrates on describing entities, data types, relationships, user operations and constraints.
Data Independence
Data independence can be 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. Two types of data independences are : Logical data independence: is the capacity to change the conceptual schema without having to change external schemas or application programs. Physical data independence: is the capacity to change the internal schema without having to change the conceptual schema.
Data Model: A set of concepts to describe the structure of a database, and certain constraints that the database should obey. Provide data abstraction
Data Model Operations: Operations for specifying database retrievals and updates by referring to the concepts of the data model.
generic operation: insert, delete, modify, retrieve
user-defined operations
2-2
- Physical (low-level, internal) data models: Provide concepts that describe details of how data is stored in the computer. record formats record ordering access paths
- Implementation (record-oriented) data models: Provide concepts that fall between the above two, balancing user views with some computer storage details. relational network hierarchical
2-2 6
Conceptual Models
High level Example: Entity-relationship diagrams Uses concepts such as
Entity: Real-world thing that is described in the database Attribute: Property of an entity Relationship: Association between entities
Logical Models
More specific than conceptual models Follow rules of a particular method of implementing a database Most common: Relational model Others
Logical independence
Physical independence
Entity-Relationship Model
Example of schema in the entityrelationship model
schema construct
2-4
13
define
empty state load initial state update state
valid state
satisfy database schema
update
2-3
14
Defines DBMS schema at three levels: (see 2-9) - Internal schema at the internal level to describe data storage structures and access paths. Typically uses a physical data model. - Conceptual schema at the conceptual level to describe the structure and constraints for the whole database. Uses a conceptual or an implementation data model. - External schema at the external level to describe the various user views. Usually uses the same data model as the conceptual level or high-level data model.
Mappings among schema levels are also needed. Programs refer to an external schema, and are mapped by the DBMS to the internal schema for execution 2-5 15
Figure 2.2
2-6
2-6
16
By adding or removing a record type or data item to expand the database (2-11) reduce the database Logical Data Independence: The capacity to change the conceptual schema without having to change the external schemas and their application programs. Physical Data Independence: The capacity to change the internal schema without having to change the conceptual schema. Reorganize physical files to improve performance e.g. List all sections offered in Fall 1998 When a schema at a lower level is changed, only the mappings between this schema and higher-lever schemas need to be changed in a DBMS that fully supports data independence. The higher-level schemas themselves are unchanged. Hence, the application programs need not be changed since they refer to the external schemas.
Disadvantages of two levels of mappings: Overhead during compilation or execution of a query or program
2-7 17
UNIVERSITY Conceptual Schema STUDENT (Name, Student Number, Class, Major) COURSE (Course Name, Course Number, Credit, Dept) PREREQUISITE (Course Number, Prerequisite Number) SECTION (Section Id, Course Number, Semester, Year, Instructor) GRADE_REPORT(Student Number, Section Id , Grade) UNIVERSITY External Schema TRANSCRIPT(Student Name, Course Number, Grade, Semester, Year, Section Id) derived from STUDENT, SECTION, GRADE_REPORT PREREQUISITES(Course Name, Course Number, Prerequisites) derived from PREREQUISITE, COURSE
Change GRADE-REPORT Schema Construct GRADE_REPORT (Student Number, Student Name, Section Id, Course Number, Grade) Change Mapping (& View Definition) TRANSCRIPT derived from SECTION, GRADE_REPORT
2-7a 18
- DML commands (data sublanguage) can be embedded in a general-purpose programming language (host language).
- Alternatively, stand-alone DML commands can be applied directly (query language).
2-8 19
21
Figure 2.3
2-11 22
2.4.2
2-12
23
Communications Facilities - Allow users at locations remote from the database system site to access the database. DB (DBMS)/DC (Data Communication System)
2-12 24
Based on the data model used: Data models -Traditional: Relational, Network (see 2-19), Hierarchical - Emerging: Object-oriented, Semantic, Entity- Relationship, other. Other classifications: Number of users : Single-user (typically used with personal computers) vs. multi-user (most DBMSs)
Number of sites: Centralized (uses a single computer) vs. distributed (uses multiple computers). Homogeneous vs. Heterogeneous Cost of DBMS software. $10,000~100,000 $100~3,000 Types of access paths used. (inverted file structures, ) Purpose general purpose special purpose e.g. airline reservations, telephone directory, on-line transaction processing system
2-13 25
Figure 2.4
A Network Schema
2-14
26