Consider the two relations with their schemas as listed below: Employee(name, empID, birthDate, gender, address, phone) TaxAccount(name, SSN, empID, federalDeductionAmt, stateDeductionAmt, ficaDeductionAmt) Constraint: TaxAccount must contain information related to all current employees only. Express the foreign key constraint in SQL.

Respuesta :

Answer:

CREATE TABLE TaxAccount (

Name int NOT NULL,

SSN int NOT NULL,

empID int FOREIGN KEY REFERENCES employee(empID),

federalDeductionAmt int NOT NULL,

stateDeductionAmt int NOT NULL,

ficaDeductionAmt int NOT NULL

);

Explanation:

TaxAccount table will use the primary key of employees table 'empID' which will serve as foreign key in TaxAccount table.

Therefore TaxAccount table will look like this:

CREATE TABLE TaxAccount (

Name int NOT NULL,

SSN int NOT NULL,

empID int FOREIGN KEY REFERENCES employee(empID),

federalDeductionAmt int NOT NULL,

stateDeductionAmt int NOT NULL,

ficaDeductionAmt int NOT NULL

);

Otras preguntas