Geeks Talk

Prepare for your Next Interview




doubt in sql

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...


Go Back   Geeks Talk > Databases > SQL

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 02-29-2008
Banned
 
Join Date: Feb 2008
Location: bangalore
Posts: 32
Thanks: 9
Thanked 2 Times in 2 Posts
jayanth511 is on a distinguished road
doubt in sql

what is the differene between referential key and foreign key with some sql query examples detaily plssss
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 02-29-2008
Junior Member
 
Join Date: Jan 2007
Posts: 10
Thanks: 0
Thanked 3 Times in 3 Posts
gssharma_msc is on a distinguished road
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.
Reply With Quote
The Following User Says Thank You to gssharma_msc For This Useful Post:
  #3 (permalink)  
Old 02-29-2008
Expert Member
 
Join Date: Sep 2007
Posts: 754
Thanks: 22
Thanked 64 Times in 63 Posts
krishnaindia2007 is on a distinguished road
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)
);
Reply With Quote
  #4 (permalink)  
Old 02-29-2008
Banned
 
Join Date: Feb 2008
Location: bangalore
Posts: 32
Thanks: 9
Thanked 2 Times in 2 Posts
jayanth511 is on a distinguished road
Re: doubt in sql

what are column level constraint and table level constraint?
Reply With Quote
  #5 (permalink)  
Old 02-29-2008
Expert Member
 
Join Date: Sep 2007
Posts: 754
Thanks: 22
Thanked 64 Times in 63 Posts
krishnaindia2007 is on a distinguished road
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.
Reply With Quote
  #6 (permalink)  
Old 03-03-2008
Moderator
 
Join Date: Jun 2007
Location: Bangalore,India
Posts: 1,432
Thanks: 8
Thanked 126 Times in 113 Posts
debasisdas will become famous soon enoughdebasisdas will become famous soon enough
Re: doubt in sql

You can't define a NOT NULL constraint at table level in oracle.
Reply With Quote
Reply

  Geeks Talk > Databases > SQL


Thread Tools
Display Modes


Similar Threads

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


All times are GMT -4. The time now is 09:50 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Copyright © 2008 GeekInterview.com. All Rights Reserved