From 712c477a0d1ab9b7c4ce45148d6ec37e5961f0c6 Mon Sep 17 00:00:00 2001 From: Reid Phillips Date: Mon, 6 Jan 2020 22:02:25 -0600 Subject: [PATCH 1/2] Employee and activeuser table definitions --- Employee.sql | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 Employee.sql diff --git a/Employee.sql b/Employee.sql new file mode 100644 index 0000000..9be330b --- /dev/null +++ b/Employee.sql @@ -0,0 +1,46 @@ +CREATE TABLE employee ( + id uuid NOT NULL DEFAULT gen_random_uuid(), + employeeid int NOT NULL DEFAULT(0), + firstname character varying(128) NOT NULL DEFAULT(''), + lastname character varying(128) NOT NULL DEFAULT(''), + password bytea NOT NULL DEFAULT(''), + active boolean NOT NULL DEFAULT(FALSE), + classification int NOT NULL DEFAULT(0), + managerid uuid NOT NULL DEFAULT CAST('00000000-0000-0000-0000-000000000000' AS uuid), + createdon timestamp without time zone NOT NULL DEFAULT now(), + CONSTRAINT employee_pkey PRIMARY KEY (id) +) WITH ( + OIDS=FALSE +); + +-- A cheap way to prevent malicious actors from using employee IDs to determine +-- how many employees are in your company. Obviously this is not foolproof. +CREATE SEQUENCE employee_employeeid_seq AS int START WITH 253 INCREMENT BY 7 OWNED BY employee.employeeid; + +ALTER TABLE employee ALTER employeeid SET DEFAULT nextval('employee_employeeid_seq'); + +CREATE INDEX ix_employee_employeeid + ON employee + USING btree(employeeid); + +----- +CREATE TABLE activeuser ( + id uuid NOT NULL DEFAULT gen_random_uuid(), + employeeid uuid NOT NULL, + name character varying(256) NOT NULL DEFAULT(''), + classification int NOT NULL DEFAULT(0), + sessionkey character varying (128) NOT NULL DEFAULT(''), + createdon timestamp without time zone NOT NULL DEFAULT now(), + CONSTRAINT activeuser_pkey PRIMARY KEY (id) +) WITH ( + OIDS=FALSE +); + +CREATE INDEX ix_activeuser_employeeid + ON activeuser + USING btree(employeeid); + +CREATE INDEX ix_activeuser_sessionkey + ON activeuser + USING btree(sessionkey); + From a1f1b5d4d92e074ff2eb7af5f31670093cacafbd Mon Sep 17 00:00:00 2001 From: odessamarahelie <46230255+odessamarahelie@users.noreply.github.com> Date: Tue, 31 Mar 2020 21:15:43 -0500 Subject: [PATCH 2/2] This is the sql script for the transaction tables --- Transaction.sql | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Transaction.sql diff --git a/Transaction.sql b/Transaction.sql new file mode 100644 index 0000000..c3b036c --- /dev/null +++ b/Transaction.sql @@ -0,0 +1,29 @@ +-- ALTER TABLE product DROP COLUMN price; + ALTER TABLE product + ADD COLUMN price bigint NOT NULL DEFAULT(0); + +-- DROP TABLE transaction; +CREATE TABLE transaction ( + id uuid NOT NULL DEFAULT gen_random_uuid(), + cashierid uuid NOT NULL DEFAULT CAST('00000000-0000-0000-0000-000000000000' AS uuid), + total bigint NOT NULL DEFAULT(0), -- There are many ways to represent monetary values, this is one: the number of cents + transactiontype int NOT NULL DEFAULT(0), + transactionreferenceid uuid NOT NULL DEFAULT CAST('00000000-0000-0000-0000-000000000000' AS uuid), + createdon timestamp without time zone NOT NULL DEFAULT now(), + CONSTRAINT transaction_pkey PRIMARY KEY (id) +) WITH ( + OIDS=FALSE +); + +-- DROP TABLE transactionentry; +CREATE TABLE transactionentry ( + id uuid NOT NULL DEFAULT gen_random_uuid(), + transactionid uuid NOT NULL DEFAULT CAST('00000000-0000-0000-0000-000000000000' AS uuid), + productid uuid NOT NULL DEFAULT CAST('00000000-0000-0000-0000-000000000000' AS uuid), + quantity decimal(15, 4) NOT NULL DEFAULT(0), + price bigint NOT NULL DEFAULT(0), -- There are many ways to represent monetary values, this is one: the number of cents + createdon timestamp without time zone NOT NULL DEFAULT now(), + CONSTRAINT transactionentry_pkey PRIMARY KEY (id) +) WITH ( + OIDS=FALSE +);