This repository has been archived by the owner on Nov 30, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Dawn Pattison <[email protected]> Co-authored-by: catherinesmith <[email protected]> Co-authored-by: Catherine Smith <[email protected]>
- Loading branch information
1 parent
7f2be16
commit 6b1baaf
Showing
20 changed files
with
706 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
USE master; | ||
|
||
-- CREATE USER IF NOT EXISTS 'sa'@'mssql_example' IDENTIFIED BY 'Mssql_pw1'; | ||
-- GRANT ALL PRIVILEGES ON *.* TO 'sa'@'mssql_example' ; | ||
-- GRANT ALL PRIVILEGES ON *.* TO 'sa'@'%' ; | ||
-- FLUSH PRIVILEGES; | ||
|
||
DROP DATABASE IF EXISTS mssql_example; | ||
CREATE DATABASE mssql_example; | ||
USE mssql_example; | ||
|
||
DROP TABLE IF EXISTS report; | ||
DROP TABLE IF EXISTS service_request; | ||
DROP TABLE IF EXISTS login; | ||
DROP TABLE IF EXISTS visit; | ||
DROP TABLE IF EXISTS order_item; | ||
DROP TABLE IF EXISTS orders; | ||
DROP TABLE IF EXISTS payment_card; | ||
DROP TABLE IF EXISTS employee; | ||
DROP TABLE IF EXISTS customer; | ||
DROP TABLE IF EXISTS address; | ||
DROP TABLE IF EXISTS product; | ||
DROP TABLE IF EXISTS composite_pk_test; | ||
DROP TABLE IF EXISTS type_link_test; | ||
|
||
|
||
CREATE TABLE product ( id INT PRIMARY KEY, name CHARACTER VARYING(100), price MONEY); | ||
|
||
CREATE TABLE address ( id BIGINT PRIMARY KEY, house INT, street CHARACTER VARYING(100), city CHARACTER VARYING(100), state CHARACTER VARYING(100), zip CHARACTER VARYING(100)); | ||
|
||
CREATE TABLE customer ( id INT PRIMARY KEY, email CHARACTER VARYING(100), name CHARACTER VARYING(100), created DATETIME, address_id BIGINT); | ||
|
||
CREATE TABLE employee ( id INT PRIMARY KEY, email CHARACTER VARYING(100), name CHARACTER VARYING(100), address_id BIGINT); | ||
|
||
CREATE TABLE payment_card ( id CHARACTER VARYING(100) PRIMARY KEY, name CHARACTER VARYING(100), ccn BIGINT, code SMALLINT, preferred BIT, customer_id INT, billing_address_id BIGINT); | ||
|
||
CREATE TABLE orders ( id CHARACTER VARYING(100) PRIMARY KEY, customer_id INT, shipping_address_id BIGINT, payment_card_id CHARACTER VARYING(100)); | ||
|
||
CREATE TABLE order_item ( order_id CHARACTER VARYING(100), item_no SMALLINT, product_id INT, quantity SMALLINT, CONSTRAINT order_item_pk PRIMARY KEY (order_id, item_no)); | ||
|
||
CREATE TABLE visit ( email CHARACTER VARYING(100), last_visit DATETIME, CONSTRAINT visit_pk PRIMARY KEY (email, last_visit)); | ||
|
||
CREATE TABLE login ( id INT PRIMARY KEY, customer_id INT, time DATETIME); | ||
|
||
CREATE TABLE service_request ( id CHARACTER VARYING(100) PRIMARY KEY, email CHARACTER VARYING(100), alt_email CHARACTER VARYING(100), opened DATE, closed DATE, employee_id INT); | ||
|
||
CREATE TABLE report ( id INT PRIMARY KEY, email CHARACTER VARYING(100), name CHARACTER VARYING(100), year INT, month INT, total_visits INT); | ||
|
||
CREATE TABLE composite_pk_test ( id_a INT NOT NULL, id_b INT NOT NULL, description VARCHAR(100), customer_id INT, PRIMARY KEY(id_a, id_b)); | ||
|
||
INSERT INTO composite_pk_test VALUES (1,10,'linked to customer 1',1), (1,11,'linked to customer 2',2), (2,10,'linked to customer 3',3); | ||
|
||
CREATE TABLE type_link_test ( id CHARACTER VARYING(100) PRIMARY KEY, name CHARACTER VARYING(100)); | ||
|
||
-- Populate tables with some public data | ||
INSERT INTO product VALUES (1, 'Example Product 1', '$10.00'), (2, 'Example Product 2', '$20.00'), (3, 'Example Product 3', '$50.00'); | ||
|
||
INSERT INTO address VALUES (1, '123', 'Example Street', 'Exampletown', 'NY', '12345'), (2, '4', 'Example Lane', 'Exampletown', 'NY', '12321'), (3, '555', 'Example Ave', 'Example City', 'NY', '12000'), (4, '1111', 'Example Place', 'Example Mountain', 'TX', '54321'); | ||
|
||
|
||
INSERT INTO customer VALUES (1, '[email protected]', 'John Customer', '2020-04-01 11:47:42', 1), (2, '[email protected]', 'Jill Customer', '2020-04-01 11:47:42', 2), (3, '[email protected]', 'Jane Customer', '2020-04-01 11:47:42', 4); | ||
|
||
|
||
INSERT INTO employee VALUES (1, '[email protected]', 'Jack Employee', 3), (2, '[email protected]', 'Jane Employee', 3); | ||
|
||
INSERT INTO payment_card VALUES ('pay_aaa-aaa', 'Example Card 1', 123456789, 321, 1, 1, 1), ('pay_bbb-bbb', 'Example Card 2', 987654321, 123, 0, 2, 1), ('pay_ccc-ccc', 'Example Card 3', 373719391, 222, 0, 3, 4); | ||
|
||
|
||
INSERT INTO orders VALUES ('ord_aaa-aaa', 1, 2, 'pay_aaa-aaa'), ('ord_bbb-bbb', 2, 1, 'pay_bbb-bbb'), ('ord_ccc-ccc', 1, 1, 'pay_aaa-aaa'), ('ord_ddd-ddd', 1, 1, 'pay_bbb-bbb'), ('ord_ddd-eee', 3, 4, 'pay-ccc-ccc'); | ||
|
||
|
||
INSERT INTO order_item VALUES ('ord_aaa-aaa', 1, 1, 1), ('ord_bbb-bbb', 1, 1, 1), ('ord_ccc-ccc', 1, 1, 1), ('ord_ccc-ccc', 2, 2, 1), ('ord_ddd-ddd', 1, 1, 1), ('ord_eee-eee', 3, 4, 3); | ||
|
||
|
||
INSERT INTO visit VALUES ('[email protected]', '2021-01-06 01:00:00'), ('[email protected]', '2021-01-06 01:00:00'); | ||
|
||
INSERT INTO login VALUES (1, 1, '2021-01-01 01:00:00'), (2, 1, '2021-01-02 01:00:00'), (3, 1, '2021-01-03 01:00:00'), (4, 1, '2021-01-04 01:00:00'), (5, 1, '2021-01-05 01:00:00'), (6, 1, '2021-01-06 01:00:00'), (7, 2, '2021-01-06 01:00:00'), (8, 3, '2021-01-06 01:00:00'); | ||
|
||
|
||
INSERT INTO service_request VALUES ('ser_aaa-aaa', '[email protected]', '[email protected]', '2021-01-01', '2021-01-03', 1), ('ser_bbb-bbb', '[email protected]', null, '2021-01-04', null, 1), ('ser_ccc-ccc', '[email protected]', null, '2021-01-05', '2020-01-07', 1), ('ser_ddd-ddd', '[email protected]', null, '2021-05-05', '2020-05-08', 2); | ||
|
||
INSERT INTO report VALUES (1, '[email protected]', 'Monthly Report', 2021, 8, 100), (2, '[email protected]', 'Monthly Report', 2021, 9, 100), (3, '[email protected]', 'Monthly Report', 2021, 10, 100), (4, '[email protected]', 'Monthly Report', 2021, 11, 100); | ||
|
||
INSERT INTO type_link_test VALUES ('1', 'name1'), ('2', 'name2'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.