my table
create table coursedept (did (pk,fk,varchar(50),notnull,
(cid (pk,fk,varchar(50),notnull) )
how to add pk and fk for same column
ive already created did(department table ) and cid(course table) with primary key i need to combined these two table
coursedept(did ,cid)
pls help me how to do it
Sachin SinghPosted Dec 18, 2022, 6:57 PM
see,
there can be unlimited number of foreign keys in a table, so did and cid can easily be marked as foreign key.
second, yes we can have two primary keys we call them composite key.
Your bridge table should look like this
Rajeev KumarPosted Feb 22, 2023, 5:36 AM
Mahesh ChandPosted Dec 18, 2022, 5:15 AM
Here is the detailed tutorial on this topic: Constraints in SQL Server (c-sharpcorner.com)
https://www.c-sharpcorner.com/UploadFile/f0b2ed/constraints-in-sql-server/
Deepak TewatiaPosted Dec 17, 2022, 4:46 PM
Hi Jaya Prakash,
you can use the following query: