0% found this document useful (0 votes)
35 views3 pages

CREATE TABLE Departments and Employees

The document contains SQL commands to create two tables: 'departments' and 'employees', along with their respective fields and constraints. It includes insertion of multiple records into both tables, defining relationships between employees and departments through foreign keys. The data includes various attributes such as department names, employee details, and their associated managers and salaries.

Uploaded by

kenomeshack
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views3 pages

CREATE TABLE Departments and Employees

The document contains SQL commands to create two tables: 'departments' and 'employees', along with their respective fields and constraints. It includes insertion of multiple records into both tables, defining relationships between employees and departments through foreign keys. The data includes various attributes such as department names, employee details, and their associated managers and salaries.

Uploaded by

kenomeshack
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

CREATE TABLE departments (

departmentID int PRIMARY KEY,


departmentName nvarchar(30) NOT NULL,
managerID int,
);

INSERT INTO departments VALUES


( 10, 'Administration', 200),
( 20, 'Marketing', 201),
( 50, 'Shipping', 124),
( 60, 'IT', 103),
( 80, 'Sales', 149),
( 90, 'Executive', 100),
( 110, 'Accounting', 205),
( 190, 'Contracting', NULL);

CREATE TABLE employees (


employeeID int PRIMARY KEY,
firstName nvarchar(20),
lastName nvarchar(25),
email nvarchar(25) NOT NULL,
phoneNumber nvarchar(20),
hireDate smallDateTime NOT NULL DEFAULT (getdate()),
jobID nvarchar(10) NOT NULL,
monthlySalary decimal(8,2),
commissionPercent decimal(2,2),
managerID int,
departmentID int,
);

ALTER TABLE employees


ADD CONSTRAINT emp_dept_fk
FOREIGN KEY (departmentID) REFERENCES
departments(departmentID);

INSERT INTO employees VALUES

( 100,'steven','king','SKING','515.123.4567',CONVERT(date,'06/17/17',1),'AD_PRES',2
4000,NULL,NULL,90),

( 101,'Neena','Kochhar','NKOCHHAR','515.123.4568',CONVERT(date,'09/21/19',1),'A
D_VP',17000,NULL,100,90),
( 102,'Lex','De
Haan','LDEHAAN','515.123.4569',CONVERT(date,'01/13/13',1),'AD_VP',17000,NULL,1
00,90),

( 103,'Alexander','Hunold','AHUNOLD','590.423.4567',CONVERT(date,'01/03/20',1),'I
T_PROG',9000,NULL,102,60),

( 104,'bruce','Ernst','BERNST','590.423.4568',CONVERT(date,'05/21/11',1),'IT_PROG',
6000,NULL,103,60),

( 107,'Diana','Lorentz','DLORENTZ','590.423.5567',CONVERT(date,'02/07/19',1),'IT_P
ROG',4200,NULL,103,60),

( 124,'KEVIN','Mourgos','KMOURGOS','650.123.5234',CONVERT(date,'11/16/19',1),'S
T_MAN',5800,NULL,100,50),

( 141,'Trenna','rajs','TRAJS','650.121.8009',CONVERT(date,'10/17/15',1),'ST_CLERK',3
500,NULL,124,50),

( 142,'Curtis','Davies','CDAVIES','650.121.2994',CONVERT(date,'01/29/17',1),'ST_CLE
RK',3100,NULL,124,50),
( 143,'Randall','Matos','RMATOS','650.121.2874',CONVERT(date,'03/15/18',1),'ST_CL
ERK',2600,NULL,124,50),

( 144,'Peter','MacDougall','PMACDOUGALL','650.121.2004',CONVERT(date,'07/09/18'
,1),'ST_CLERK',2500,NULL,124,50),

( 149,'Eleni','Zlotkey','EZLOTKEY','011.44.1344.429018',CONVERT(date,'01/29/20',1)
,'SA_MAN',10500,.2,100,80),

( 174,'Ellen','ABEL','EABEL','011.44.1644.429267',CONVERT(date,'05/11/16',1),'SA_R
EP',11000,.30,149,80),

( 176,'Jonathon','Taylor','JTAYLOR','011.44.1644.429265',CONVERT(date,'03/24/18',1)
,'SA_REP',8600,.20,149,80),

( 178,'Kimberely','Grant','KGRANT','011.44.1644.429263',CONVERT(date,'05/24/19',
1),'SA_REP',7000,.15,149,NULL),

( 200,'Jennifer','Whalen','JWHALEN','515.123.4444',CONVERT(date,'09/17/07',1),'AD_
ASST',4400,NULL,101,10),

( 201,'Michael','Hartstein','MHARTSTE','515.123.5555',CONVERT(date,'02/17/16',1),'
MK_MAN',13000,NULL,100,20),

( 202,'Pat','Fay','PFAY','603.123.6666',CONVERT(date,'08/17/17',1),'MK_REP',6000,N
ULL,201,20),

( 205,'Shelley','Higgins','SHIGGINS','515.123.8080',CONVERT(date,'06/07/14',1),'AC_
MGR',12000,NULL,101,110),

( 206,'William','Gietz','WGIETZ','515.123.8181',CONVERT(date,'06/07/14',1),'AC_ACC
OUNT',8300,NULL,205,110);

You might also like