SQL Server Database Setup

SQL Simulator Setup

The first thing you will need to do is to set up blank schema for the SQL Simulator to run in. It is important that you set this blank schema up in a non production database. Use the below script for this task:

CREATE LOGIN sql_simulator_1   
    WITH PASSWORD = '12345';  
GO  

CREATE USER sql_simulator_1 FOR LOGIN sql_simulator_1;  
GO  

CREATE SCHEMA sql_simulator_1;
GO

Next please run the following in a different database than the one you used to create the sql_simulator_1 schema.

CREATE TABLE employees
( employee_id int NOT NULL PRIMARY KEY,
  employee_ssn varchar(9) NOT NULL,
  employee_first_name varchar(50) NOT NULL,
  employee_last_name varchar(50) NOT NULL,
  employee_address varchar(50) NOT NULL,
  city varchar(50),
  state varchar(50),
  zip varchar(50)
);


CREATE TABLE payroll (
    payroll_id int NOT NULL PRIMARY KEY,	
	paycheck_status varchar(1),
    account_number varchar(20),
    employee_id int  REFERENCES employees(employee_id)
);


insert into employees (employee_id, employee_ssn, employee_first_name, employee_last_name, employee_address, city, state, zip) 
values (1,'123456789', 'MARTINEZ','RODRIGUEZ', '110 WEATHERSFIELD DR','chester','va','21111');

insert into employees (employee_id, employee_ssn, employee_first_name, employee_last_name, employee_address, city, state, zip) 
values (2,'223466781', 'THOMAS','SMITH', '124 NEW CASTLE DR','chester','va','21111');

insert into employees (employee_id, employee_ssn, employee_first_name, employee_last_name, employee_address, city, state, zip) 
values (3,'323476782', 'WHITE','LOPEZ', '364 LEIGH FARM RD','chester','va','21111');

insert into employees (employee_id, employee_ssn, employee_first_name, employee_last_name, employee_address, city, state, zip) 
values (4,'423486783', 'HARRIS','WILLIAMS', '413 NOTTINGHAM DR','chester','va','21111');

insert into employees (employee_id, employee_ssn, employee_first_name, employee_last_name, employee_address, city, state, zip) 
values (5,'523496784', 'jason','LEWIS', '5006 MILL HILL LN','chester','va','21111');



insert into payroll (payroll_id, employee_id, paycheck_status, account_number) 
values (6, 1, 'S','00001234');
insert into payroll (payroll_id, employee_id, paycheck_status, account_number) 
values (7, 2, 'S','00001234');
insert into payroll (payroll_id, employee_id, paycheck_status, account_number) 
values (8, 3, 'S','00001234');
insert into payroll (payroll_id, employee_id, paycheck_status, account_number) 
values (9, 4, 'S','00001234');
insert into payroll (payroll_id, employee_id, paycheck_status, account_number) 
values (10, 5, 'S','00001234');

Last updated