diff --git a/Censis/OBrand/OBrand_postgres_create.sql b/Censis/OBrand/OBrand_postgres_create.sql new file mode 100644 index 0000000..81035d8 --- /dev/null +++ b/Censis/OBrand/OBrand_postgres_create.sql @@ -0,0 +1,101 @@ +CREATE TABLE "logins" ( + "id" serial NOT NULL, + "username" varchar(100) NOT NULL UNIQUE, + "password_salt" varchar(128) NOT NULL UNIQUE, + "password_hash" varchar(78) NOT NULL, + "password_reset_token" varchar(128) NOT NULL UNIQUE, + CONSTRAINT logins_pk PRIMARY KEY ("id") +) WITH ( + OIDS=FALSE +); + + + +CREATE TABLE "profile" ( + "id" serial NOT NULL, + "user_id" int NOT NULL, + "forename" varchar(75) NOT NULL, + "surname" varchar(75) NOT NULL, + "gender" int NOT NULL, + "dob" DATE NOT NULL, + "bio" TEXT NOT NULL, + "member_of" TEXT, + CONSTRAINT profile_pk PRIMARY KEY ("id") +) WITH ( + OIDS=FALSE +); + + + +CREATE TABLE "company" ( + "id" serial NOT NULL, + "company_name" varchar(100) NOT NULL, + "address1" varchar(150) NOT NULL, + "address2" varchar(150) NOT NULL, + "address3" varchar(150) NOT NULL, + "town" varchar(150) NOT NULL, + "county" varchar(150) NOT NULL, + "postcode" varchar(12) NOT NULL, + "country" int NOT NULL, + "pcontact" varchar(20) NOT NULL, + "ocontact" varchar(20) NOT NULL, + "mobile" varchar(20) NOT NULL, + "email" varchar(150) NOT NULL, + CONSTRAINT company_pk PRIMARY KEY ("id") +) WITH ( + OIDS=FALSE +); + + + +CREATE TABLE "venue" ( + "id" serial NOT NULL, + "venue_name" varchar(100) NOT NULL, + "address1" varchar(150) NOT NULL, + "address2" varchar(150) NOT NULL, + "address3" varchar(150) NOT NULL, + "town" varchar(150) NOT NULL, + "county" varchar(150) NOT NULL, + "postcode" varchar(12) NOT NULL, + "country" int NOT NULL, + "pcontact" varchar(20) NOT NULL, + "ocontact" varchar(20) NOT NULL, + "mobile" varchar(20) NOT NULL, + "email" varchar(150) NOT NULL, + "company_id" int NOT NULL, + CONSTRAINT venue_pk PRIMARY KEY ("id") +) WITH ( + OIDS=FALSE +); + + + +CREATE TABLE "billing" ( + "id" serial NOT NULL, + "company_id" int NOT NULL, + CONSTRAINT billing_pk PRIMARY KEY ("id") +) WITH ( + OIDS=FALSE +); + + + +CREATE TABLE "master_beacons" ( + "id" bigint NOT NULL, + "uid" uuid NOT NULL, + CONSTRAINT master_beacons_pk PRIMARY KEY ("id") +) WITH ( + OIDS=FALSE +); + + + + +ALTER TABLE "profile" ADD CONSTRAINT "profile_fk0" FOREIGN KEY ("user_id") REFERENCES "logins"("id"); +ALTER TABLE "profile" ADD CONSTRAINT "profile_fk1" FOREIGN KEY ("member_of") REFERENCES "company"("id"); + + +ALTER TABLE "venue" ADD CONSTRAINT "venue_fk0" FOREIGN KEY ("company_id") REFERENCES "company"("id"); + +ALTER TABLE "billing" ADD CONSTRAINT "billing_fk0" FOREIGN KEY ("company_id") REFERENCES "company"("id"); + diff --git a/Censis/OBrand/database.md b/Censis/OBrand/database.md new file mode 100644 index 0000000..b4bbecc --- /dev/null +++ b/Censis/OBrand/database.md @@ -0,0 +1,62 @@ +#Database + +##User / Account Management + +###logins +* *id* +* username +* password_salt +* password_hash +* password_reset_token + +> Use BCrypt to generate to password_hash, the password_salt might not be required. + +> Password reset token to be used when someone forgets their password, the email should be sent to them with the hashed token. + +###profile +* *id* +* uid * -> logins:id* +* forename +* surname +* gender +* dob +* bio +* member_of * -> company:id* + +##Venue / Company + +###company +* *id* +* company_name +* address1 +* address2 +* address3 +* town +* county +* postcode +* country +* pcontact +* ocontact +* mobile +* email + +###billing +* *id* +* cid * -> company:id* + +###venue +* *id* +* cid * -> company:id* +* venue_name +* address1 +* address2 +* address3 +* town +* county +* postcode +* country +* pcontact +* ocontact +* mobile +* email +