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

Ch 2 Data Models 1 Data Models .

Data Model: A set of concepts to describe the structure of a database, and certain constraints that the database should obey. Most data models also include a set of basic operations. . Data Model Operations: Operations for specifying database retrievals and updates by referring to the concepts of the data model. . Categories of data models . Conceptual (high-level, semantic) data models: Provide concepts that are close to the way many users perceive data. It includes entity-based or object-oriented data models. . Physical (low-level, internal) data models: Provide concepts that describe details of how data is stored in the computer such as record formats, record ordering, and access path. . Implementation (representational, record-oriented) data models: Provide concepts that fall between the above two, balancing user views with some computer storage details (hide some details of data storage but can be implemented on a computer in a direct way and represent data by using record structures).
1

. Implementation data models include: relational, network, hierarchical, object-oriented. 2 Schemas and Instances . Database Schema: The description of a database. It includes descriptions of the database structure and the constraints that should hold on the database. The DBMS stores the schema information in the DBMS catalog so that DBMS software can refer to the schema whenever it needs to. . Schema Diagram: A diagrammatic display of some aspects of a database schema. Some aspects may not be specified in the schema diagram. . Database Instance: The actual data stored in a database at a particular moment in time. Also called database state or set of occurrences. . The distinction between database schema and database state is very important. When we define a new database, we only specify its database schema to the DBMS. At this point, the corresponding database state is the empty state with no data. We get the initial state of the database when the data is first loaded. . The database schema changes very infrequently. The database state changes every time the database is updated. Schema is
2

also called the intension, whereas a state is called an extension of the schema. 3 Three Schema Architecture . Proposed to support three DBMS characteristics of . Insulation of programs and data. . Support of multiple user views. . Use of a catalog to store the database description (schema). . Defines DBMS schemas at three levels. The purpose is to separate the user applications and the physical database. Most DBMS do not separate the three levels completely, but several of them support the three-schema architecture to some extent. . The external schema at the external or view level is used to describe the part of the database that a particular user group is interested in and hides the rest of the database from that user group. A high-level data model or an implementation data model can be used at this level. . The conceptual schema at the conceptual level describes the structure of the whole database for a community of users. It hides the details of physical storage structures and describes entities, data types, relationships, user operations, and constraints for the whole database.
3

Uses a high-level or an implementation data model. . The internal schema at the internal level describes the physical storage structures and access paths. Typically uses a physical data model. . The three schemas are only descriptions of data; the only data that actually exists is at the physical level. In a DBMS based on the three-schema architecture, . Each user group refers to its own external schema, . DBMS transform a request specified on an external schema into a request against the conceptual schema, and then into a request on the internal schema for processing over the stored database; if the request is a retrieval, the data extracted must be reformatted to match the user's external view. . The processes of transforming requests and results between levels are called mappings. 4 Data Independence . The three-schema architecture can be used to explain the concept of data independence, which 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. There are two types of data independence:
4

. Logical data independence is the capacity to change the conceptual schema (for example, to expand the database by adding a new record type or data item or to reduce the database by removing a record type or data item) without having to change the external schemas or application programs. . In the latter case, external schemas that refer only to the remaining data should not be affected. . Physical data independence is the capacity to change the internal schema (for improving retrieval or updating) without having to change the conceptual or external schemas. If the same set of data as before remains, we don't need to change the conceptual schema. . The DBMS uses software to accomplish mappings by referring to the mapping information in the catalog. . When the schema is changed at some level, the schema at the next higher level remains unchanged; only the mapping between the two levels is changed. Application programs referring to the higher-level schema need not be changed. 5 Database Languages . Data Definition Language (DDL): Used by the DBA and database designers to specify both conceptual and internal
5

schema of a database. . In DBMSs where a separation is maintained between the conceptual and internal levels, the DDL is also used to specify the conceptual schema only. A separate language the storage definition language (SDL) is used to specify the internal schema. For a true three-schema architecture, the view definition language (VDL) is used to specify user views and their mappings to the conceptual schema. . Data Manipulation Language (DML): Used to specify database retrieval, insertion, deletion and modification. . DML commands can be embedded in a general-purpose programming language, that language is called the host language such as COBOL, C or C++, the DML is called the data sublanguage. In OO systems, the host and data sublanguages typically form one integrated language such as C++. . Alternatively, stand-alone DML commands can be applied directly (query language). . Currently, a comprehensive integrated language is used that includes constructs for conceptual schema definition, view definition, data manipulation and storage definition. SQL represents a combination of DDL, VDL, DML, and SDL, although the SDL is now being removed from the language. . Types of DML
6

. Procedural DML: Also called record-at-a-time or low-level DML. Must be embedded in a programming language. Searches for and retrieves individual database records, and uses looping and other constructs of the host programming language to retrieve multiple records. . Declarative or non-procedural DML: Also called set-at-a -time, set-oriented or high-level DML. Can be used as a stand-alone query language or can be embedded in a programming language. A query in a declarative DML often specifies what data is to be retrieved rather than how to retrieve the data. 6 DBMS Interfaces . Stand-alone query language interfaces. . Programmer interfaces for embedding DML in programming languages: . Pre-compiler Approach . Procedure (subroutine) Call Approach . In OO systems, the host and data sublanguages form one integrated language such as C++. . User-friendly interfaces:
7

. Menu-based interfaces . Graphical interfaces . Forms-based interfaces . Natural language interfaces . Combinations of the above . Parametric interfaces using function keys . Interfaces for the DBA: . Creating accounts, granting authorizations . Setting system parameters . Changing schemas or access path 7 Database System Utilities . To perform certain functions such as: . Loading data stored in files into a database. . Backing up the database periodically on tape.
8

. Reorganizing database file structures. . Report generation utilities. . Performance monitoring utilities. . Other functions, such as sorting, user monitoring, data compression, etc. . Data dictionary system . Used to store catalog information about schemas and constraints, as well as design decisions, application program descriptions, user information, usage standards, etc. . Active data dictionary (a combined catalog/data dictionary) is accessed by DBMS software and users/DBA. . Passive data dictionary is accessed by users/DBA only. 8 Database System Structure . Storage Manager . Authorization and integrity manager . Transaction manager
9

. File manager . Buffer manager . Query Processor . DDL interpreter . DML compiler . Query evaluation engine

10

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