PRIMARY KEY VS FOREIGN KEYS SSMS (2019) EXPRESS

Kosovari_ 81 Reputation points
2021-09-30T02:00:53.3+00:00

I have three tables at SQL SERVER 2019 described below:

Table DEPARTMENTS : Columns DeptID , DeptName example FINANCE, IT .

Table EMPLOYEE : Columns : employeeID , SupervisorID .

Table SUPERVISOR : Columns : FirstName, LastName, SupervisorID, DeptID .

HOW TO EXECUTE ON QUERY in SQL SYNTAX OF PRIMARY KEYS AND FOREIGN KEYS FOR THESE THREE TABLES???

THANK YOU DEAREST FRIENDS . YOUNG KOSOVAR CITIZEN FROM KOSOVO ..

Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,554 questions
{count} votes

Accepted answer
  1. Erland Sommarskog 101.4K Reputation points MVP
    2021-09-30T21:25:30.177+00:00

    Some sample statements to get you started:

    ALTER TABLE Department ADD CONSTRAINT pk_Department PRIMARY KEY(DeptId)
    ALTER TABLE Supervisor ADD 
       CONSTRAINT fk_Supervisor_Department 
       FOREIGN KEY (DeptID) REFERENCES (DeptID)
    
    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful