I have always wanted to know how to create Relationships between "2 Tables"
in a Database.
As I would like to build/Design a web site like Planet? (But not as a Competitor)
But dedicated
To one type of Programming Language : Delphi.
I was informed that if I do decide to design a site like this, then I would have
to make
Access Database - Table-Relationships. OK, but could not find any information
on how
to do it. Then I came across it last night: September 24, 2004. And man
oh man, I was a very
Happy person :-)
OK. Lets get on with the lesson on Creating Table Relationships in Access.
Lets start out by opening up "Access" (I am using Access 2000,
Hopefully it will be
The same in all versions, if not, please read up on " Relationships "
in the Access Help)
Lets create a new Database. Lets give it the name of: [Relations]
Now lets click on [Design View]
In [Design View]. Type in the following
FieldName......................DataType
========================
ID....................................AutoNumber
(Make ID the [Primary Key])
UserID..............................text
UserPass...........................text
Choose to [Save] with name: [ Users ]
Next lets create another Table. By clicking on
[Design View] again. And typing in this
FieldName......................DataType
========================
ID...................................AutoNumber
(Make ID the [Primary Key])
FName.............................text
LName.............................text
UEmail..............................text
UAddress..........................text
UPhone.............................text
UZip...............................text
UState...............................text
[Save] this Table with name: [UInfo]
===========================
Now that we have are "2" Tables
Table: Users
Table: UInfo
Created, it is time to create the [Database Table Relationships] Between
them.
So are you ready to learn something that know one will show/tell you how to
do?
Alrighty then, lets Rock and Roll the Database, into High Gear.
==============
In the Database [Relationships] you see your 2-Tables.
[Right Click] Anywhere in the "White Area" Around the Tables
(But not on the Tables) And choose: "Relationships...."
When the [Relationships] Dialog Box, appears, it will show you all the
Tables.
That is in our Database. Choose [Users] & [UInfo] from the
list.
And choose [Add]
They will appear behind the "Show Tables" Dialog, So lets close
the " Show Tables" Dialog.
And now you see both Tables. [Users] & [UInfo].
--------------------
In this next step, we have to decide which area that we want to create the
Relationship for?
So we are going to create the Relations between the " 2 - ID
" Fields, since these are
[ AutoNumber ] fields, and they will stay consistent with one another,
as new records
Are recorded into it. So lets Create the Relationship, between them.
[Left Click] on the
"Users = ID"
And "Drag & Drop" over to and on top of
"UInfo = ID" Field
This will then Popup a Dialog [Edit Relationships]
Leave it Default [ID | ID] and choose [Create]
This will create a line between
Users=ID --------- UInfo=ID
That lines means that these 2 Fields in the Table are connected together.
You can now close out of the [Relationships] Dialog, and get Back to
your
Database View.
Now click on the Table: UInfo. And put some information in the Fields.
[Save] The information, then click on the Table: Users. And Add a User.
(Making sure that the User matches the Name that you create in UInfo.
So they will be the same. For each Record that is created in the Tables.
They are assigned a Unique Number for their ID. This is the AutoNumber.
So the Relationship between the "2" tables is connected by the "AutoNumber"
Of the [ID]. So if the Record you create in [UInfo] has ID#
1
Then in [Users] The new User has ID#1. Is the Same User?
So for every record that is created, make sure they there Unique ID# is the
same. )
After you have created a "New Record" in each Table, Open up each
Table.
And you should see a: [+] beside each entry.
Click on the [+] and it should show you the Relationship that corresponds
with
That Entry.
If you receive an error: Then close out of the Table, and go back into the
Relationships.... and make sure that you Create the Relationship
Between both [ID] and nothing else.
And then make sure that the [ID] in each table, is a " AutoNumber
"
And that should take care of it.
This will be posted to our "Knowledge Base" as well.
Which at the moment is secure, with no outside access.
Please check on ' www.carrz-fox-fire.com " in the near future, for a new
look
to the Internet.
Thank you and hope that this Article is helpful in your pursuit in making that
Killer ASP page.
Wayne & Carr Barron
Carrz-Fox-Fire Promotions