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?

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain different types of locks in sql server.

1013


What are the steps to follow to configure SQL*Net?

995


How to create a login account in ms sql server to access the database engine using "create login" statements?

1064


How to delete a login name in ms sql server?

1006


What are scalar functions in sql?

1080


What is the difference between sql server 2000 object owner and sql server 2005 schema? : sql server database administration

943


Explain what is dbcc?

964


What is the maximum size of column in sql server?

850


What is resource governor?

927


What are the elements of dbms?

923


Explain the dbcc pintable command when would you use it?

872


Explain primary key?

902


What are the diifferences between the ms sql server vs mysql?

1123


between cast and convert which function would you prefer and why?

917


What is a select query statement in ms sql server?

1010