Results 1 to 4 of 4
Thread: Inner-Join vs Foreign Key
Jan 4, 2005, 12:19 #1
Inner-Join vs Foreign Key
OK so i'll throw my hands up and admit- i'm somewhat a newbie in the practicalities of mysql (relationships and normal form, on the other hand, are no probs).
I've been trying to design a database where a property table holds an entry for a property that is for sale and there is one field "user-id" that I want to link to the user table so that when they select the property from the list of displayed properties I can query both tables in order to get info regarding the seller and the property.
It's a 1:many relationship (user: property) and I was wondering this...
I was going to have the "user-id" in the property table as a FK relating to the "user" table. However I've also seen that "..JOIN" statements exist and I was wondering which is the best method to use? If I use the FK do i still need to create the query with a 'join' syntax?
Jan 4, 2005, 21:05 #2
- Join Date
- Jul 2002
- Toronto, Canada
- 52 Post(s)
- 2 Thread(s)
foreign keys are used to ensure data integrity (when they are supported)
to retrieve data from two tables, you must join them, whether or not they have a relationship defined, although typically you would join them using the primary and foreign key columns
however, you can join tables on whatever columns you want, regardless of whether relationships have been defined
Jan 5, 2005, 03:46 #3
- Join Date
- Apr 2004
- 0 Post(s)
- 0 Thread(s)
Are you using MYSQL?
Im in the same boat and im using Mysql
Jan 5, 2005, 11:07 #4
Ah ha that makes sense!
r937: Thanks a lot! Makes sense now
weewizard/rich: yeah I am using mysql.