Prepare for your Next Interview
This is a discussion on Primary key & foreign key within the Oracle forums, part of the Databases category; Plz tell me with example the difference between Primary key,foreign key,unique key...
|
|||
|
Re: Primary key & foreign key
Unique Key prohibits multiple rows from having the same value in the same column or combination of columns . But it allows null values.
Primary key is a combination of UNIQUE KEY and NOT NULL. It will not allow duplicate values and null values. Foreign key ensures conformity between two tables. If a column is defined as foreign key it can contain only values from a parent table's primary key or a unique key. For examples follow the link |
|
|||
|
Re: Primary key & foreign key
Primary key---------enforces both uniqueness and not null(no duplicate and no null in the column)
foreign key----------maintains referential integrity(child record refers to parent record) unique key----------maintains uniqueness of data in the column(no duplicate records) |
|
|||
|
Re: Primary key & foreign key
primary key not accept null value & it is related with unique table while foreign
key is related with more than one table with one simillar coloumn. |
| The Following User Says Thank You to sumit palkar For This Useful Post: | ||
|
|||
|
Re: Primary key & foreign key
Quote:
primary key is key to identify uniqe record,is not null,unique,dont allow duplicate foreign kay is key which act as primary key in one table & foreign key in another table it is reference bet two table unique key is same as primary key |
|
|||
|
Re: Primary key & foreign key
primary key is combination of both unique and notnull keys.
unique key is a key which is not accept any duplication. foriegn key is a key which is act as a primary key to some other table. |
|
|||
|
Set of fields in database taken collectively to identify any row uniquely is called Candidate key...
So Database has more than 1 Candidate key... Primary key is the Candidate key choosen by the Database Designer... Unique Key is the constraint that is used to insert unique value in the field of the database... |
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| DateTime as Primary Key? | icepack2000 | Oracle | 1 | 04-22-2008 07:59 AM |
| Primary Key References | krishnaindia2007 | Oracle | 1 | 03-06-2008 07:38 AM |
| Different data type for primary and foreign keys | Geek_Guest | SQL | 3 | 11-28-2007 04:45 AM |
| Is foreign university is better to apply | Geek_Guest | Career Advice | 1 | 09-29-2007 02:42 AM |
| To handle foreign characters | janelyn | Web Design | 0 | 08-03-2006 04:08 PM |