Databases can be understood at three conceptual levels:
The external level represents the application view of the data, including application-specific semantics and constraints. For the VideoMagix application, for example, you might decide that the customer can only belong to a single club, or that a video tape can only be borrowed by one customer at a time.
The next level is the conceptual level. This is the level of entity-relationship modeling. From this perspective, we consider tables, rows, columns and indexes. A table is a structure which looks like this:
Tape ID | Title Name | Release Date | Cost | Period | Available? |
001 | Gone with the Wind | 1939 | $4.00 | 2 day | Y |
002 | Ghandi | 1982 | $3.00 | 2 day | N |
003 | 2001 | 1968 | $4.50 | 1 day | Y |
Each row represents a single record. Each column represents a field in the record. At this level, we are concerned with understanding the relationships among the various objects in the domain and how these translate to tables and their interrelationships.
The most basic level is the physical level, which corresponds directly to the contents of the disk files used to capture these data and indexes. Here, you consider questions about the size of the records in the file, data access blocks, disk access methods and so forth.
The architecture of relational databases assumes three types of users:
Each row in a table has a unique identifier. This identifier consists of one or more fields in the row. The same fields are used as the identifier for all rows in a table. This is called the primary key for the table.
Relational databases are all about relations among tables. One way for two tables to be related to one another is for Table A to contain the primary key of Table B. This is called a foreign key in Table A, and it serves as a reference to a row in Table B.
Tape Name (primary key) | Release Date | Cost | Days | Who rented (foreign key) |
Gone With The Wind | 1939 | $3.00 | 2 | 10010 |
Ghandi | 1982 | $4 | 2 | 10021 |
Table A
ID (primary key) | Name | Address | City/ State | Phone | Club? |
10021 | John Doe | 1 Main St. | Anytown | 999-123-4567 | N |
10010 | Jesse Liberty | 1 Till Dr. | Acton, MA | 617-747-7301 | Y |
Table B
In this example the
in Table B is the key on which Table B will be indexed. It is also a foreign key into Table A. If you want to find out who rented a tape listed in Table A, you look up the ID
in Table B and get the customer's record.ID
A table is always indexed on its primary key. It is also possible to index on any other field to speed up searching for a record on that field. For example, you might index
in Table B. Or, for that matter, you might index the combination of Name
and Address
as a single key. These additional indexed fields are called secondary keys.City/State
There are restrictions on the contents of the rows. For example, duplicate rows are not allowed and all primary keys must be unique within the table. The order of the rows is not important to the conceptual model, although it can be important to the physical model. The value of each field is atomic — each field represents a single, indivisible bit of information, thus, lists are not allowed within a single field.
There are three types of table: