ICT 321 DATABASE SCHEMA 1
1
ICT 321
DATABASE SCHEMA
2
Agenda
• Data model• ANSI/Spark Data Model• Database schema and instances
3
Data Models• Data Model:– A set of concepts to describe the structure of a database,
the operations for manipulating these structures, and certain constraints that the database should obey.
• Data Model Structure and Constraints:– Constructs are used to define the database structure– Constructs typically include elements (and their data
types) as well as groups of elements (e.g. entity, record, table), and relationships among such groups
– Constraints specify some restrictions on valid data; these constraints must be enforced at all times
4
Data Models (continued)• Data Model Operations:– These operations are used for specifying database
retrievals and updates by referring to the constructs of the data model.
– Operations on the data model may include basic model operations (e.g. generic insert, delete, update) and user-defined operations (e.g. compute_student_average_mark, update_inventory)
5
Categories of Data Models• Conceptual (high-level, semantic) data
models:– Provide concepts that are close to the way many
users perceive data. • (Also called entity-based or object-based data
models.)• Physical (low-level, internal) data models:– Provide concepts that describe details of how data
is stored in the computer. These are usually specified in an ad-hoc manner through DBMS design and administration manuals
6
Categories of Data Models• Implementation (representational) data
models:– Provide concepts that fall between the above two,
used by many commercial DBMS implementations (e.g. relational data models used in many commercial systems).
7
ANSI/Spark Data Model• Developed by American National Standard
Institute/ Standards Planning and Requirements Committee)
• Also known as ANSI-SPARC Three-Level Architecture
• This model provides some level of data abstraction and data independence
• Data abstraction generally refers to the suppression of details of data organization and storage, and the highlighting of the essential features for an improved understanding of data
8
ANSI/Spark Data Model• The different levels(schema) of data abstraction
are:1. Physical level or internal level2. Logical level or conceptual level3. View level or external level
9
ANSI/Spark Data Model
ANSI/Spark three level architecture diagram
10
ANSI/Spark Data Model• Data independence means the internal
structure of database should be unaffected by changes to physical aspects of storage I.e. the DBA can change the database storage structures without affecting the users view.
• The data independence can be both logical and physical
11
ANSI/Spark Data Model• Logical Data Independence: – The capacity to change the conceptual schema
without having to change the external schemas and their associated application programs.
• Physical Data Independence:– The capacity to change the internal schema without
having to change the conceptual schema.– For example, the internal schema may be changed
when certain file structures are reorganized or new indexes are created to improve database performance
12
ANSI/Spark Data Model• When a schema at a lower level is changed,
only the mappings between this schema and higher-level 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.
13
ANSI/Spark Data Model• Mappings among schema levels are needed to
transform requests and data. – Programs refer to an external schema, and are
mapped by the DBMS to the internal schema for execution.
– Data extracted from the internal DBMS level is reformatted to match the user’s external view (e.g. formatting the results of an SQL query for display in a web page)
14
ANSI/Spark Data Model• The objective of this architecture is to
separate each user’s view of the database from the way the database is physically represented. There are several reasons why this separation is desirable:1. Each user should be able to access the same
data, but have a different customized view of the data.
2. Users should not have to deal directly with physical database storage details
15
ANSI/Spark Data Model3. The DBA should be able to change the database
storage structures without affecting the users’ views.
4. The internal structure of the database should be unaffected by changes to the physical aspects of storage, such as the changeover to a new storage device.
5. The DBA should be able to change the conceptual structure of the database without affecting all users.
16
View level or external level• The users’ view of the database. • This level describes that part of the database
that is relevant to each user.• Each external schema describes the part of
the database that a particular user group is interested in and hides the rest of the database from that user group.
17
View level or external level- example
Auto insurance database: external schema.
18
Logical level or conceptual level• The community view of the database.• This level describes what data is stored in the
database and the relationships among the data.
• This level contains the logical structure of the entire database as seen by the DBA.
• The conceptual model represents a global view of the entire database as viewed by the entire organization.
19
Logical level or conceptual level• That is, the conceptual model integrates all
external views (entities, relationships, constraints, and processes) into a single global view of the data in the enterprise.
• The conceptual level represents:– all entities, their attributes, and their
relationships;– the constraints on the data;– semantic information about the data;– security and integrity information.
20
Logical level or conceptual level
Auto insurance database: conceptual schema
21
Physical level or internal level• The physical representation of the database
on the computer. This level describes how the data is stored in the database.
• The internal level is concerned with such things as:– storage space allocation for data and indexes;– record descriptions for storage (with stored sizes
for data items);– record placement;– data compression and data encryption techniques.
22
Physical level or internal level• Below this level there is where data are
managed by the operating system under the direction of the DBMS
• The internal schema uses a physical data model and describes the complete details of data storage and access paths for the database.
23
Physical level or internal level
Auto insurance database: internal schema.
24
Database Schemas• The description of a database.• The overall design of the database is called the
database schema• It is a collection of named objects which
provide a logical classification of objects in the database.
• It Includes descriptions of the database structure, data types, and the constraints on the database.
25
Database Schemas
• A schema is also an object in the database. It is explicitly created using the CREATE SCHEMA statement with the current user recorded as the schema owner.
• Schema Diagram:– An illustrative display of (most aspects of) a
database schema.• Schema Construct:– A component of the schema or an object within
the schema, e.g., STUDENT, COURSE.
26
Database SchemasSchema classification
27
Database Schemas - example
28
Database Schema - example
29
Database Instances• Database State:– The actual data stored in a database at a
particular moment in time. This includes the collection of all the data in the database.
– Also called database instance (or occurrence or snapshot).
• The term instance is also applied to individual database components, e.g. record instance, table instance, entity instance
30
database state - example
31
Database Schema vs. Database State
• Database State: – Refers to the content of a database at a moment
in time.• Initial Database State:– Refers to the database state when it is initially
loaded into the system.• Valid State:– A state that satisfies the structure and constraints
of the database.
32
Database Schema vs. Database State• Distinction– The database schema changes very infrequently. – The database state changes every time the
database is updated.