Skip to content

Commit

Permalink
Update to latest version and createst SQL scripts.
Browse files Browse the repository at this point in the history
  • Loading branch information
geosp committed May 4, 2020
1 parent 10adc1a commit c168f65
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 1 deletion.
2 changes: 1 addition & 1 deletion rdbs/mssql/mssql-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ spec:
restartPolicy: Always
containers:
- name: mssql
image: mcr.microsoft.com/mssql/server:2019-CU3-ubuntu-16.04
image: mcr.microsoft.com/mssql/server:2019-CU4-ubuntu-16.04
securityContext:
allowPrivilegeEscalation: false
runAsUser: 1000
Expand Down
71 changes: 71 additions & 0 deletions rdbs/mssql/test/create_hr_domain.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
USE master
GO
IF NOT EXISTS (
SELECT name
FROM sys.databases
WHERE name = N'hr_domain'
)
CREATE DATABASE hr_domain
GO
USE hr_domain

CREATE TABLE regions (
region_id INT IDENTITY(1,1) PRIMARY KEY,
region_name VARCHAR (25) DEFAULT NULL
);

CREATE TABLE countries (
country_id CHAR (2) PRIMARY KEY,
country_name VARCHAR (40) DEFAULT NULL,
region_id INT NOT NULL,
FOREIGN KEY (region_id) REFERENCES regions (region_id) ON DELETE CASCADE ON UPDATE CASCADE
);

CREATE TABLE locations (
location_id INT IDENTITY(1,1) PRIMARY KEY,
street_address VARCHAR (40) DEFAULT NULL,
postal_code VARCHAR (12) DEFAULT NULL,
city VARCHAR (30) NOT NULL,
state_province VARCHAR (25) DEFAULT NULL,
country_id CHAR (2) NOT NULL,
FOREIGN KEY (country_id) REFERENCES countries (country_id) ON DELETE CASCADE ON UPDATE CASCADE
);

CREATE TABLE jobs (
job_id INT IDENTITY(1,1) PRIMARY KEY,
job_title VARCHAR (35) NOT NULL,
min_salary DECIMAL (8, 2) DEFAULT NULL,
max_salary DECIMAL (8, 2) DEFAULT NULL
);

CREATE TABLE departments (
department_id INT IDENTITY(1,1) PRIMARY KEY,
department_name VARCHAR (30) NOT NULL,
location_id INT DEFAULT NULL,
FOREIGN KEY (location_id) REFERENCES locations (location_id) ON DELETE CASCADE ON UPDATE CASCADE
);

CREATE TABLE employees (
employee_id INT IDENTITY(1,1) 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 NOT NULL,
salary DECIMAL (8, 2) NOT NULL,
manager_id INT DEFAULT NULL,
department_id INT 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 IDENTITY(1,1) PRIMARY KEY,
first_name VARCHAR (50) NOT NULL,
last_name VARCHAR (50) NOT NULL,
relationship VARCHAR (25) NOT NULL,
employee_id INT NOT NULL,
FOREIGN KEY (employee_id) REFERENCES employees (employee_id) ON DELETE CASCADE ON UPDATE CASCADE
);
5 changes: 5 additions & 0 deletions rdbs/mssql/test/drop_hr_domain.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

USE master;
GO
ALTER DATABASE hr_domain SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
DROP DATABASE hr_domain

0 comments on commit c168f65

Please sign in to comment.