primary key in the Address table. Primary key and foreign key are one and the same in the
Address table. This is therefore a 1:1 relationship.
A 1:1 relationship does not signify that for every record in a table, there will be a corresponding
record in another table. But at most there will be only one corresponding record. A 1:1 relationship
therefore leads to fields being exported which will be filled with content for only some of the
records.
Tables and relationships for the example database
The example database (media_without_macros) must satisfy three requirements: media
additions and removals, loans, and user administration.
Media addition table
First, media must be added into the database so that a library can work with them. However, for a
simple summary of a media collection at home, you could create easier databases with the wizard;
that might be sufficient for home use.
The central table for media addition is the Media table (see Figure 4).
In this table all fields that are directly entered are assumed not to be also in use for other media
with the same content. Duplication should therefore be avoided.
For this reason, planned fields in the table include the title, the ISBN, an image of the cover, and
the year of publication. The list of fields can be extended if required. So, for instance, librarians
might want to include fields for the size (number of pages), the series title, and so on.
The Subtitle table contains the detailed content of CDs. As a CD can contain several pieces of
music, a record of the individual pieces in the main table would require a lot of additional fields
(Subtitle 1, Subtitle 2, etc.) or the same item would have to be entered many times. The Subtitle
table therefore stands in a n:1 relationship to the Media table.
The fields of the Subtitle table are (in addition to the subtitle itself) the sequence number of the
subtitle and the duration of the track. The Length field must first be defined as a time field. In this
way, the total duration of the CD can be calculated and displayed in a summary if necessary.
The authors have a n:m relationship to the media. One item can have several authors, and one
author might have created several items. This relationship is controlled by the rel_Media_Author
table. The primary key of this linking table is the foreign key, formed from the Author and Media
tables. The rel_Media_Author table includes an additional sorting (Author_Sort) of authors, for
example by the sequence in which they are named in the book. In addition, a supplementary label
such as Producer, Photographer and so on is added to the author where necessary.
Category, Mediastyle, Town and Publisher have a 1:n relationship.
For the Category, a small library can use something like Art or Biology. For larger libraries,
general systems for libraries are available. These systems provide both abbreviations and
complete descriptions. Hence both fields appear under Category.
The Mediastyle is linked to the loan period Loantime. For example, video DVDs might on principle
have a loan period of 7 days, but books might be loaned for 21 days. If the loan period is linked to
any other criteria, there will be corresponding changes in your methodology.
The Town table serves not only to store location data from the media but also to store the locations
used in the addresses of users.
Since Publishers also recur frequently, a separate table is provided for them.
The Media table has in total four foreign keys and one primary key, which is used as a foreign key
in two tables, as shown in Figure 4.
Relationships between tables 7