Foreign key field

D

dre

Guest
I'm new to databases and was wundering what the Foreign key field does and how to use it
 
W

wisniewski

Guest
Gives the user ( on an input form) options from another table.

Say you have three tables ( Database name = Cafe)

Menu
Dinner
Desert

Your main table menu has 2 fields - Dinner & Desert.

Instead of having to list possible choices ( from the admin page )

YOu can list choices that are input from Dinner & Desert ( Dinner has a few fields - ie ( main, side )

So....
Foreign Key field on Menu, - field Dinner would be:
Cafe_Dinner.main


Play around.
 
T

thupten

Guest
thanks a lot to wisni.. you saved me!!!
in the insert field..if you want to give option (combo box) to the user..which is the contents of another field of another table. then it is a very good idea to use the foreign key field.
i have 2 tables. the first table is of items and second table is providers.
while inserting a new record for new item, i want to put the provider name (in a combo box) along with the item fields. so i put in foreign key field 'provider.providername'

if u have only one table and u want something like that then u could just use the option field seperated by ~.
for eg. if u want to show option usa,europe,africa..put ~usa~europe~africa in the option field.
 
Top