|
-
May 23rd, 2003, 07:07 AM
#1
Thread Starter
Sleep mode
Foreign Key ?[Resolved]
What's is that in MS Access ?
Last edited by Pirate; May 23rd, 2003 at 08:18 AM.
-
May 23rd, 2003, 07:53 AM
#2
Fanatic Member
it's is a primary key in another table that is used to link the tables together.
e.g.
tblCustomer
customerID - primary key
name
etc
tblPayment
paymentID -primary key
customerID - foreign key
details etc
the tables are linked by customerID
-
May 23rd, 2003, 07:57 AM
#3
Thread Starter
Sleep mode
Thanks nswan
How would I benefit from this ?
-
May 23rd, 2003, 08:02 AM
#4
Fanatic Member
adding relationships between tables. You can do this by going to tools-relationship. This then puts the relationships in automatically when using the query builder.
-
May 23rd, 2003, 08:09 AM
#5
Thread Starter
Sleep mode
I meant Why would I need to build or set these relations between tables ? Will this give me more storage space or what ?
-
May 23rd, 2003, 08:11 AM
#6
Fanatic Member
no it's only really a use for making it supposedly easier with the query builder.
I think it'll dramatically increase the size of your database the more relationships you add as well.
I don't usually bother and just add joins manually for each query i build.
-
May 23rd, 2003, 08:16 AM
#7
Thread Starter
Sleep mode
Alright then , I guess I have to read more about it .
Thanks nswan
-
May 23rd, 2003, 10:24 AM
#8
Its a form of index and will increase the speed of your queries, as I believe indexes are checked first or something like that. Also this helps to keep your data integrity because it links the two keys in different tables together to make a relationship. Say you have a Categories table and an Items table like this:
Categories
PK_CategoryID
Name
Notes
Items
PK_ItemID
FK_CategoryID
Name
Notes
Value
Without a relationship then you could have Items with a CategoryID that doesn't match to any category in the Category table. If you have the relationship then it can check and force you to remove the items that belong to a category before removing the category itself or make sure when adding a new item that you use a valid CategoryID.
-
May 23rd, 2003, 04:52 PM
#9
Thread Starter
Sleep mode
Yeah , I remember this example Edneeis . This explains more to me . This needs more practice though . Thanks
-
May 23rd, 2003, 05:27 PM
#10
PowerPoster
You should really look into a good db book. I suggest SQL Server 2000 Programming. It is an awesome book. I know you are dealing with Access, but if you learn just the basics of DB design, you can apply it to all DB's.
think it'll dramatically increase the size of your database the more relationships you add as well.
It doesn't dramatically increase the size. Lets say the foreign key is 8 bytes. Even if you have 10,000 records, this is only taking up like 78K (plus or minus a few). That little bit of space is worth the added stability to your data.
Now, a good place to start reading about this type of stuff would be to search for 'entity relationships'. Also, 'normalization' is another term to start reading up on.
Here is a link to get you started:
http://www.informit.com/content/inde...-2E8EFAF74708}
-
May 24th, 2003, 11:33 AM
#11
Thread Starter
Sleep mode
Great link hellswraith . Now I really realized how important relational database . Thanks for that .
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|