Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

Employee Attribute Data Type Primary Foreign Constraint SSN Number Charr(9) Check Not Null First Name VarChar(15) Not Null MidName Char Last Name VarChar(15) Not Null

Employee
Attribute Data Type Primary Foreign Constraint
SSN Number Charr(9) Check Not Null
First Name VarChar(15) Not Null
MidName Char
Last Name VarChar(15) Not Null
Birthday Date

Gender Char

Gender CHECK

('M','F','m','f')

Salary Money DEFAULT '80000'
Supervisor SSN Char(9) employee(SSN)
Department Number

Int

Department
Attribute Data Type Primary Foreign Constraint
Department Name VarChar(15) Not Null
Department Number Int Check Not Null
Manager SSN Char(9)

Employee(SSN)

ON DELETE SET NULL

Not Null
Manage Start Date Date

I need to make a foreign key with Manager SSN that relates to Employee SSN, but every time I try to put it in SQL it doesn't allow it due to referential integrity constraints.

My Code in MySQL is as follows:

Alter Table Department_JCS Add Constraint Department_fk Foreign Key (ManagerSSN) References Employee_JCS(EmployeeSSN) On Delete Set Null Go

And the problem I get is:

Msg 1761, Level 16, State 1, Server DESKTOP-54BQ7EN\LOCALDB#743D77CD, Line 1 Cannot create the foreign key "Department_fk" with the SET NULL referential action, because one or more referencing columns are not nullable.

What must I change in order to allow the constraint?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

What is Larmors formula? Explain with a suitable example.

Answered: 1 week ago