David said:
Hello All,
I can't for the life of me understand table relationships and how they work.
I've tried reading up on it on Microsofts website but it sounds really
confusing. Any other sites where it might explain it better? Is the reason I
don't understand because my database has five tables in it and none of the
fields are the same or relate to any other table? Should I make another table
and combine all the fields from the other five so that I can relate them?
TIA,
David
<major db neepery>
IMO, there is no way getting around understanding the basics.
The trouble could come from the fact that Relation, Relations, and
Relationship(s) have multiple meanings in regards to "Relational
Databases."
One meaning, is that the underlying theory behind Relational Databases is a
branch of math called Relational Algebra (invented by Dr. Codd). This
branch of math works on "sets" of data. A "set" in Relational Algebra is
called a "relation" (don't ask me why . . .). Then, some people in various
companies (IBM, Oracle, etc.) took this branch of math and made it into the
precursors of the Relational Databases apps we have today (they grabbed
"relational" off of Relational Algebra and stuck it in front of "database",
and voila, we have "Relational Databases").
Now, in order to run our databases, we have something that goes by the
technical term, Referential Integrity. This states that if we start with
Table CustomerMaster, that has a Primary Key of SocialSecurityNumber, and we
have Table CustomerPhone, that also has a column called SocialSecurityNumber
(so that we know who the phone numbers belong to); whatever happens, we
don't want to have a row in the CustomerPhone table that has a Social
Security Number that doesn't appear in CustomerMaster. Why? Because we'd
have phone numbers in CustomerPhone that belonged to no one we could
identify (there being nothing in CustomerMaster). Relational Databases use
internal management, and indexes, to *enforce* a "rule" that automatically
prevents users from deleting any row in CustomerMaster . . . *when there is
still any row* . . . in CustomerPhone with the Social Security Number about
to be deleted from CustomerMaster. This process, this "enforcement" of the
"rules", is called Referential Integrity.
Now, in MS Access, you open up the "Relationships" window, and drag fields
back and forth and establish nice little lines that go from table to table,
and MS Access calls these lines "Relationships" (and a lot of other people
do, too). In this case, an MS Access "Relationship" is the method whereby
"Referential Integrity" is set up.
To further confuse the issue (yes, there's more), Data Modeling, the process
where ideas about things are organized into understandable formats, like big
charts covered by boxes with lines running between them (rather remarkably
like the boxes and lines in the MS Access Relationships window), also call
their lines "relationships".
Is there more? Yes. Relationships in Data Modeling and Relationships in
generic Database Design (the process of planning out and building a
database; which, ideally, proceeds from a completed Data Model) are similar,
but not the same.
In Database Design, relationships frequently refer to the establishment of
Referential Integrity (RI).
Now, jumping a little out of the relationship picture, we go further into
Database Design. There are three main rules of good table design. They are
Called First Normal Form, Second Normal Form, and Third Normal Form (often
abbreviated 1NF, 2NF, and 3NF). There's also BCNF and 4NF. These rules,
when followed, among other things, make establishing RI easier (they make
the whole DB Design process easier, most of the time). Look them these
rules on the internet (you may already have, I am sliding away from the
original topic).
</major db neepery>