Beruflich Dokumente
Kultur Dokumente
The first thing you'll need to do is to save the database. This may seem
strange, since other applications allow you to add text or create objects and
then save, but this is what Access requires. You are defining, or creating, a
database structure by saving it, and that structure will be the only way to
access the tables and queries created in it.
Note
The screen shots in Labs 11-13 may
look somewhat different than what
appears on your own computer. Dont
be concerned unless your windows and
menus appear significantly different.
For this exercise you will be working on paper. Each time you build a
database you must think about the structure you will be creating. This part
of the lab will help you understand the basic structure of this database. Read
through the description and then follow the steps listed at the end.
The Advisor table will hold data about the advisor. This table
should contain attributes for Advisor ID, Last Name, First
Name, and Department..
Advising
Advisor Student
(One to Many)
tblStudent
Student ID
Last Name
First Name
Major
Student's Advisor
C. For each attribute, assign a shorter, one-word name. Listed below are
the names that will be used in the rest of this lab:
Fname Text
Department Text
You now have two tables holding data related to two different
entitiesStudent entity and Advisor entity.
Note
Note
A number appears once you put your cursor in the Lname column and
start typing "Dickey". This is the primary key for each row. It is
generated by Access so that every row is unique, and so there will never
be a null value in the AdvisorID column. AutoNumber is not required
when establishing a primary key in Access. It is simply a convenient way
to assign one, if an attribute does not exist that is known to be unique
and not null
Note
You do not have to save tables when you enter data in the datasheet view. The
table is automatically saved for you. If you change the way the table "looks" (the
display/format), then you do need to save it, to preserve the format you have
created.
6. Establish Relationships in the Relationships Window
Go to Tools>Relationships;
OR
Find the icon on the Tool Bar;
OR
Right click while on the database window.
The infinity
symbol indicates
the "many" side
of the relationship
Note
If you do not see an infinity symbol, it's because you did not check the
Enforce Referential Integrity checkbox. Right-click on the line linking the
two entities and select Edit Relationships You will be taken back to the
Edit Relationships dialog box, where you will be able to check the Enforce
.Referential Integrity checkbox. This relationship causes Access to verify
you are entering relationships that exist in related tables
Normalization
Let's start to normalize one of the two tables you have created. This process
is usually done before creating table structures, but we are going through it
on a database that has already been created, so you get an idea of how it is
done.
Currently your database consists of two tables. The Student table includes
textual information about another potential entity. This means it's possible
that values in some of the columns may be filled with redundant information.
Can you identify the column that holds semantic (textual, meaningful)
information about a separate "thing" in the student table? Take a close look
at the Major attribute. We will be separating this attribute out into a
separate table.
For our database, a student will only be allowed to declare one major. This
will maintain a one-to-many relationship between the Student and Major
entities.
C. Now create a table called tblMajor in your access database with the
following attributes:
and
Looking Forward:
Domain Integrity:
A rule in database design is that any
attributes that are part of a relationship
between two tables must have the same
data type. This is called "maintaining
domain integrity".
B. Select the field Major, and right-click. From the menu that
pops up, select Delete Rows.
C. When asked if you want to "permanently Delete the
selected fields", click Yes.
D. Now the old attribute Major and all the corresponding data
in your table have been removed.
Note
The MajorID attribute will hold the key numbers that correspond
with particular instances of the Major entity. It is placed in the
Student table to show the major the student has declared. (The
attribute AdvisorID is used in the same way.)
A. Associate the Major table with the Student table, based on the
MajorID.
B. Create the relationship and enforce referential integrity.
C. Refer to Exercise 7 if you need more help on establishing relationships.
ALERT!! If your database is open when you transfer your files, you may
end up transferring an empty file. If you need to save the file to a different
location, such as your hard drive or a server such as dante, be sure you
close down your database completely first!