Hi All,
i have confusing little here..what is the actual use of foriegn key an primary key relations .can we bind the date using this relation only...if we want records from both tables which contains PK andFK relation any way we use joins .then what is actuall use of these. can any one explain me with real time example
Nitin SontakkePosted Jul 25, 2016, 11:42 PM
I understand your confusion. You are saying if I can get data from joining the keys what bother defining the keys.
However, as Francis already mentioned, PK and FK work as a constraints. Meaning, you cannot insertNULL in a PK column and you cannot insert duplicate value in PK column. Similarly, while you can insert NULL in FK column (if it is nullable) you cannot insert a value in a FKcolumn which is not present in PK column in another table to which FK column references.
kalu singh raoPosted Jul 25, 2016, 4:14 AM
Francis SusaimichaelPosted Jul 25, 2016, 4:08 AM
In real time, what is the relationship abouta boy andanother man in the same family? Can you guess it. Nope. because it may be Son & father orgrandson& father etc.So the "relationship" definesit. So you name it at least to define. This is where the "relationship" will come. Normally a primary key, isavailable inside a Table. If you want to relate the 2 tables Foreign key comesto picture.