Prepare for your Next Interview
This is a discussion on doubt in sql within the SQL forums, part of the Databases category; what is the differene between referential key and foreign key with some sql query examples detaily plssss...
|
|||
|
Re: doubt in sql
In the context of relational databases, a foreign key is a referential constraint between two tables.[1] The foreign key identifies a column or a set of columns in one (referencing) table that refers to a column or set of columns in another (referenced) table. The columns in the referencing table must form a primary key or unique key. The values in one row of the referencing columns must occur in a single row in the referenced table. Thus, a row in the referencing table cannot contain values that don't exist in the referenced table. This way references can be made to link information together and it is an essential part of database normalization. Multiple rows in the referencing table may refer to the same row in the referenced table. Most of the time, it reflects the one (master table, or referenced table) to many (child table, or referencing table) relationship.
|
| The Following User Says Thank You to gssharma_msc For This Useful Post: | ||
|
|||
|
Re: doubt in sql
1.Reference key is another name for foreign key. Both are same.
2.Examples for foreign key You may define foreign key at Table level Column Level Example for table level constraint Create table emp ( Empno Varchar2(6), ename varchar2(30), deptno number (2) , constriant dept_emp foreign key(deptno) references table(deptno)); Example for column level Create table emp ( Empno Varchar2(6), ename varchar2(30), deptno number (2) references dept(deptno) ); |
|
|||
|
Re: doubt in sql
Column level constraints are those, which we can specify while specifying the column itself.
Table level constrains are those which we can specify after all columns have been specified. |
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| doubt in sql | jayanth511 | SQL | 3 | 02-28-2008 11:15 PM |
| a doubt.... | Ammu_R | PHP | 1 | 08-17-2007 10:51 AM |
| doubt | Santhana KrishnaN | C# | 3 | 06-07-2007 11:42 PM |
| doubt in qtp | thejovathich | QTP | 2 | 04-30-2007 08:02 AM |
| doubt reg bug in SRS and FRS | venkatsagehill | Testing Issues | 3 | 02-19-2007 07:59 AM |