Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


can foreign key take role of primary key?

Answers were Sorted based on User's Feedback



can foreign key take role of primary key? ..

Answer / gaurav

Yes. This situation occurs in one-to-one relationships.

For example:

create table Table1
( T1_Id integer not null primary key
, T1_Data varchar(9) not null
)
create table Table2
( T2_Id integer not null primary key
, T2_Data varchar(37) not null
, foreign key (T2_Id) references Table1 (T1_Id)
)

Why would someone design two tables like this? If it's a
one-to-one relationship, couldn't you just include T2_Data
in Table1? Yes, you could, although then you would also need
to allow T2_Data to be NULL, if not every T1_Id has a
matching T2_Id—in this case it's actually a
one-to-zero-or-one relationship.

If it's a true one-to-one relationship, where every T1_Id
has a matching T2_Id, then you could combine them without
NULLs. Then the only reason why you might want separate
tables would be if T2_Data were (a) infrequently queried,
and (b) so large that it would result in many fewer physical
rows on a physical database page, which would imply poorer
performance for queries that used only T1_Data.

Is This Answer Correct ?    10 Yes 0 No

can foreign key take role of primary key? ..

Answer / @panwar

yes but for same table and if you use foriegn key as a
primary key for same table then there will be no benifit of
master-detail concept for it relation.
and if you follow the Master_detail concept then you can't
use as primary key for another table.

Is This Answer Correct ?    9 Yes 2 No

can foreign key take role of primary key? ..

Answer / kkk

No foreign key cant take role of primary key

Is This Answer Correct ?    7 Yes 4 No

can foreign key take role of primary key? ..

Answer / radhakrishnan vaithilingam

no,foreign key is possible for null value in column.
this rules not matching with PK.

Is This Answer Correct ?    2 Yes 1 No

can foreign key take role of primary key? ..

Answer / suresh murugadass

Yes. It is possible in this scenario. Here table has a
self join. Since emp_id represents both emp_id and mgr_id
this is possible a primary key to behave as foriegn key
create table emp(
emp_id int not null primarykey,
emp_name varchar2(40) not null,
mgr_id int not null foriegn key(mgr_id) references emp(emp_id)
}

Is This Answer Correct ?    2 Yes 2 No

Post New Answer

More SQL Server Interview Questions

Explain some stored procedure creating best practices or guidelines?

0 Answers  


What is the difference between ‘having’ clause and a ‘where’ clause?

0 Answers  


please bar with my english i having a database called tblhallreservation in which res_date is date field has to select all the fields in table deponding on month either has to display all details for the month jan or feb and so on

1 Answers  


What is the difference between a function and a trigger?

0 Answers  


What all db objects can be found in MSDB database of a SQL Server instance?

2 Answers   Accenture,


When cursors are useful?

0 Answers  


Do you know what is bit data type and whats the information that can be stored inside a bit column?

0 Answers  


What are a scheduled jobs?

0 Answers  


Explain what are page splits? : SQL Server Architecture

0 Answers  


How do I uninstall sql server 2014?

0 Answers  


What is set nocount on and what is set nocount off?

0 Answers  


1.What is the deferece between DBMS & RDBMS? 2.How can you trouble shoot? If u will get error while installing sql server? 3.How can u trouble shoot slow running query? 4.how can u trouble log shipping errors? 5.why do we use merge replication instead of T.log replication?

7 Answers   Microsoft,


Categories