|
CSCI A114 / INFO I111
|
A Database System
Let us consider an enterprise, such as an airline, that has a large amount of data kept for long periods of time in a computer. This data might include information about
Typical RELATIONSHIPS that might be represented include:
The software that allows one or many persons to use and/or modify this data is called a DATABASE MANAGEMENT SYSTEM (DBMS).
Roles of the DBMS
Levels of Abstraction in a DBMS
Here's a diagram of this:
Schemes and Instances
When a database is designed, we are interested in plans for the database.
When the database is used, we are interested (and working with) the actual data present in the database.
Definitions
The current contents of a database we term an INSTANCE of the database.
The plans regarding the organization of a database are called a database SCHEME. Plans consist of an enumeration of the
Observation 2: The term scheme is used to refer to plans so we talk of a
The conceptual scheme is an abstraction of the real world pertinent to an enterprise. It is roughly at the level of passengers, flights, and so on which we have discussed in connection withm the enterprise of an airline.
A DBMS provides a DATA DEFINITION LANGUAGE to specify the conceptual scheme and, most likely, some of the details regarding the implementation of the conceptual scheme by the physical scheme.
The data definition language is a high-level language, enabling one to describe the conceptual scheme in terms of a DATA MODEL.
The choice of a data model is a difficult one, since it must be rich enough in structure to define significant aspects of the real world, yet it must be possible to determine fairly automatically an efficient implementation of the conceptual scheme by a physical scheme.
Our choice of a data model is the relational data model.
The Relational Data Model
This model is based on the set theoretic notion of a relation.
A relation is a set of k-tuples, for some fixed k.
For example: bookings could be represented by a set BOOKINGS of triples:
so(FLIGHT_NO, DATE, PASSENGER)
BOOKINGS = { (n, d, p) | passenger p has a reservation on flight n on date d}An Example
Let us now undertake the design of a (somewhat) complete database for an airline using the entity relationship model.
First we list the entity sets and their attributes.
Then we describe the relationships.
1. The Entities
Entity set PASSENGERS with attributes:
NAME amd ADDRESS together should uniquely identify a passenger.NAME CHAR(30) ADDRESS CHAR(30) PHONE INT(10)
Entity set FLIGHTS with attributes:
For simplicity we assume that flights don't make intermediary stops.NUMBER INT(3) SOURCE CHAR(3) DEST CHAR(3) DEP_TIME INT(4) ARR_TIME INT(4)
The NUMBER of a flight should uniquely identify a flight.
The SOURCE is an airport. All commercial airports have three character letter codes (e.g., ORD, IND, JFK etc.) DEST is also an airport. Departure time and arrival time are in military format.
Entity set DEPARTURES with attribute:
We assume that dates are numbered from the beginning of the current year (1-366).DATE INT(3)
Entity set PLANES with attributes:
The two attributes together uniquely identify the type of plane.MANUFACTURER CHAR(10) MODEL_NO CHAR(10)
Example: Boeing (Manufacturer), 747 (Model_No).
Entity set AIRCRAFT with attribute:
We presume that serial numbers are assigned by the airline and serve as a key for each aircraft owned by the airline. This entity set contains individual aircraft.SERIAL_NO INT(5)
Entity set PERSONNEL with attributes:
Knowing the EMP_NO makes it clear what employee we're talking about.EMP_NO INT(6) NAME CHAR(30) ADDRESS CHAR(30) SALARY INT(6)
Entity set PILOTS (subset of EMPLOYEES) with no additional attributes.
Relationships:
| one | PILOTS | [1] IS_A | PERSONNEL | one |
| many | PILOTS | [2] CAN_FLY | PLANES | many |
| many | PASSENGERS | [3] BOOKED_ON | DEPARTURES | many |
| many | DEPARTURES | [4] INSTANCE_OF | FLIGHTS | one |
| many | PERSONNEL | [5] ASSIGNED_TO | DEPARTURES | many |
| many | AIRCRAFT | [6] TYPE | FLIGHTS | one |
Note that in this diagram the relationships appear as columns in the tables and the design is complete.
A114/I111