1 / 2

Creating Employee Table with Referential Integrity in SQL

This SQL code defines the structure for the Employee table (EMP) with multiple constraints to ensure data integrity. The table includes columns for employee name (ENAME), social security number (ESSN), birth date (BDATE), department number (DNO), and supervisor's social security number (SUPERSSN). It enforces primary key on the ESSN column and establishes foreign key relationships with the Department (DNO) and supervisor (SUPERSSN) with specific actions on delete and update to maintain referential integrity.

wang-hodges
Télécharger la présentation

Creating Employee Table with Referential Integrity in SQL

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. REFERENTIAL INTEGRITY CREATE TABLE EMP (ENAME VARCHAR(30) NOT NULL, ESSN CHAR(9), BDATE DATE, DNO INTEGER DEFAULT 1, SUPERSSN CHAR(9), PRIMARY KEY (ESSN), FOREIGN KEY (DNO) REFERENCES DEPT(Dnm) ON DELETE SET DEFAULT ON UPDATE CASCADE, FOREIGN KEY (SUPERSSN) REFERENCES EMP(ssn) ON DELETE SET NULL ON UPDATE CASCADE );

More Related