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)
thank you very much dearest bro FROM Kosova.
Do I need to add Employees with ALTER TABLE Or not?
Since I don't know your requirements I cannot say what you need. But it seems reasonable that Employees would have an FK to Supervisor. And a primary key. As I said, the above is only a sample. The rest is left as an exercise to the reader.
Sign in to comment
PRIMARY KEY VS FOREIGN KEYS SSMS (2019) EXPRESS
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 ..
What are the primary keys and foreign keys of the three tables? And what query do you want to execute?
Query to execute and for add three tables to add primary key and foreign syntax example ???
What are you doing with these three tables? You mentioned that you need to use primary and foreign keys, so we need to know which columns their primary and foreign keys are. The primary key and foreign key are one or more columns of the table.
Good day and welcome tot he QnA forum @Kosovari_ ,
I have three tables
Where are the tables?!?
Your message include only a poor description of columns names.
Please provide queries to create the tables including any index, constraints, and relations. In addition please provide queries to INSERT some sample data for the discussion, and please describe your expected result SET according to the sample data which you inserted using the sample queries. Thanks
This information will help us to preproduce the scenario
Sign in to comment