Lesson 3: Data and Relations

Schemas

The Three Schema Architecture

A schema is a description of data contents, structure, and possibly other aspects of a database

The separation of external schema from conceptual schema enables logical data independence. The separation of conceptual schema from internal schema enables physical data independence.

Data Independence

Isolates applications from data description and changes to data. Data structure description is stored separately from the access programs. In a database, if a record structure is changed by adding a field, then the new field shows up on the next access of the database. The DBMS itself does not need to be changed in order for it to access the data. The details of storage implementation are hidden from the user.

Relational Model

A domain is a set of atomic values. An atomic value is a value that is indivisible; i.e. it cannot be broken down into smaller values. This depends partly on how the value is to be used. A Name attribute (ex: "David B. Brown") may be considered atomic if only the entire name value is used. However a Name could be broken down into Surname , Forename , and Initial should there be a use for the individual attributes. On the other hand a student ID would be irreducibly atomic in that it cannot be broken down further.

If an attribute is multivalued it should be represented by separate relations. Thus if a supervisor has many employees this information cannot be stored in a single table because employees is multivalued. The relationship between the two must be broken up into at least two tables.

Keys

Generally all tuples in a relation should be distinct

Key constraints between tables are called referential integrity constraints.

DDL / DML

DDL: Data Definition Language


DML: Data Manipulation Language

SQL (Structured Query Language) is used as both a DDL and a DML.

Constraints

A referential key constraint can protect data in one table from deletions or updates in another table.

A referential key constraint can also make deletions and updates easier.

The database designer must choose whether a particular relation rejects or cascades deletions and updates.