The document contains SQL statements that create tables for a database including tables for regions, countries, locations, jobs, departments, employees, dependents, and job status with columns and foreign key constraints defined.
Download as TXT, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
15 views
Create Table in SQL
The document contains SQL statements that create tables for a database including tables for regions, countries, locations, jobs, departments, employees, dependents, and job status with columns and foreign key constraints defined.
department_id INT (11) AUTO_INCREMENT PRIMARY KEY, department_name VARCHAR (30) NOT NULL, location_id INT (11) DEFAULT NULL, FOREIGN KEY (location_id) REFERENCES locations (location_id) ON DELETE CASCADE ON UPDATE CASCADE );
CREATE TABLE employees (
employee_id INT (11) AUTO_INCREMENT PRIMARY KEY, first_name VARCHAR (20) DEFAULT NULL, last_name VARCHAR (25) NOT NULL, email VARCHAR (100) NOT NULL, phone_number VARCHAR (20) DEFAULT NULL, hire_date DATE NOT NULL, job_id INT (11) NOT NULL, salary DECIMAL (8, 2) NOT NULL, manager_id INT (11) DEFAULT NULL, department_id INT (11) DEFAULT NULL, FOREIGN KEY (job_id) REFERENCES jobs (job_id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (department_id) REFERENCES departments (department_id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (manager_id) REFERENCES employees (employee_id) );
CREATE TABLE dependents (
dependent_id INT (11) AUTO_INCREMENT PRIMARY KEY, first_name VARCHAR (50) NOT NULL, last_name VARCHAR (50) NOT NULL, relationship VARCHAR (25) NOT NULL, employee_id INT (11) NOT NULL, FOREIGN KEY (employee_id) REFERENCES employees (employee_id) ON DELETE CASCADE ON UPDATE CASCADE );
CREATE TABLE jobstatus (
job_id INT (11) AUTO_INCREMENT PRIMARY KEY, job_title VARCHAR (35) NOT NULL, job_status VARCHAR (35) NOT NULL, );