‎2007 May 02 3:23 PM
HI TO ALL CAN U PLS GIVE DETAILED DESCRPTION ON
PLS DONT GIVE ANY SITE LINKS TRY TO GIVE ON UR OWN WORDS
what is the primary key .and tell the purpose of it?
what is the compound foreign key and purpose of it?
‎2007 May 02 3:27 PM
Primary key: is the combination of fields in a database table which can help u to identify a unique record in the table, i.e., u can only have 1 record for the combination of primary key fields of a database table.
‎2007 May 02 3:28 PM
Please do not use all Capital letters.
It is like shouting.
Primary Key is a unique identifier for a record.
For example, if you are in a class room, and somebody wants to call you, there is a chance that more than one person has the same name. hence name is not a primary key.
If they call by roll number, only one person will respond.
hence roll number is a primary key in this example.
Hope you understand.
regards,
ravi
‎2007 May 02 3:29 PM
Hi Kumar,
Primary key defines a record in a table. So in a table you cannot have more than one record with the same key value.
Sometimes the value of a field in a table is determined by the values from another table. Or values that field can occupy is limited to values from another table. There
you define foreign key. I am not aware of compound foreign key.
Regards,
Aravind
‎2007 May 02 3:34 PM
Hi,
A set of fields of a table which would uniquely identify rows of the table is called
Primary key.
The word compound as prefix to primary key or foreign key means the same.
If the key contains more than one field its called compound.
Foriegn key is something through which you can Refrential entity relationship.
that means how two tables are related.
For examples.
Employee can work in various departments
But department numbers should exist in department table.
so Deptno serves as foreign key between department and employee tables
‎2007 May 02 3:35 PM
Foreign keys are used as check tables.
suppos ethere is a table to enter a students marks. ZSTUDMARK
fields are like.
student id
subject code
session
marks.
suppose when sombody key in data,
they shud not enter junk like 123 for student code. when someone key in syudent code, 3456, there shud be such a student code existing in the student master table say ZSTUDENT.
to make sur ethat, entries in ZSTUDMARK student id column are valid, this column of ZSUDMARK shud have a check table . and this check table must be, ZSTUDENT-STUDENTID. this relation is called foreign key
similarly when some onter a subject it shud be a valid subject , and that shud be verified against zstsubject table which have subject codes.