1 | drop schema if exists project cascade;
|
---|
2 | create schema project;
|
---|
3 |
|
---|
4 | drop table if exists User_;
|
---|
5 | drop table if exists BuildMuscleProgram;
|
---|
6 | drop table if exists Workout;
|
---|
7 | drop table if exists WeightLossProgram;
|
---|
8 | drop table if exists Supplements;
|
---|
9 | drop table if exists LoyalityCardUser;
|
---|
10 | drop table if exists NoLoyalityCardUser;
|
---|
11 | drop table if exists Program;
|
---|
12 | drop table if exists MealPlan;
|
---|
13 | drop table if exists Payment;
|
---|
14 |
|
---|
15 |
|
---|
16 |
|
---|
17 | CREATE TABLE User_(
|
---|
18 | user_id serial PRIMARY KEY,
|
---|
19 | name_surname VARCHAR (255),
|
---|
20 | account_number INTEGER,
|
---|
21 | card_number INTEGER,
|
---|
22 | password VARCHAR (255) NOT NULL,
|
---|
23 | tel_num VARCHAR (255) NOT NULL,
|
---|
24 | address (255) NOT NULL,
|
---|
25 | e-mail (255) NOT NULL,
|
---|
26 | height INTEGER,
|
---|
27 | weight INTEGER,
|
---|
28 | );
|
---|
29 | CREATE TABLE BuildMuscleProgram (
|
---|
30 | bm_p serial PRIMARY KEY,
|
---|
31 | user_id INTEGER REFERENCES User(user_id),
|
---|
32 | meal VARCHAR(20);
|
---|
33 | );
|
---|
34 | CREATE TABLE Workout(
|
---|
35 | w_id serial PRIMARY KEY,
|
---|
36 | name VARCHAR (255) NOT NULL,
|
---|
37 | user_id INTEGER REFERENCES User(user_id),
|
---|
38 | w_id VARCHAR (255) NOT NULL,
|
---|
39 | );
|
---|
40 | CREATE TABLE WeightLossProgram(
|
---|
41 | wl_p serial PRIMARY KEY,
|
---|
42 | user_id INTEGER REFERENCES User(user_id),
|
---|
43 | calories INTEGER NOT NULL,
|
---|
44 | meal VARCHAR (255) NOT NULL;
|
---|
45 | );
|
---|
46 | CREATE TABLE Supplements(
|
---|
47 | supplement_id serial PRIMARY KEY,
|
---|
48 | user_id INTEGER REFERENCES User(user_id),
|
---|
49 | preworkouts VARCHAR (255) ,
|
---|
50 | proteins VARCHAR (255),
|
---|
51 | creatine VARCHAR (255),
|
---|
52 | fat_burners VARCHAR (255),
|
---|
53 | vitamins_ minerals VARCHAR (255),
|
---|
54 | aminos VARCHAR (255);
|
---|
55 | );
|
---|
56 | CREATE TABLE LoyalityCardUser(
|
---|
57 | user_id INTEGER REFERENCES User(user_id),
|
---|
58 | loyality_card_number serial PRIMARY KEY,
|
---|
59 | discount INTEGER ,
|
---|
60 | price float NOT NULL;
|
---|
61 | );
|
---|
62 | CREATE TABLE NoLoyalityCardUser(
|
---|
63 | user_id INTEGER REFERENCES User(user_id),
|
---|
64 | price FLOAT NOT NULL,
|
---|
65 | ordinal_user serial PRIMARY KEY;
|
---|
66 | );
|
---|
67 | CREATE TABLE Program(
|
---|
68 | user_id INTEGER REFERENCES User(user_id),
|
---|
69 | program_name VARCHAR (255),
|
---|
70 | program_id serial PRIMARY KEY;
|
---|
71 | );
|
---|
72 |
|
---|
73 | CREATE TABLE MealPlan(
|
---|
74 | meal_id serial PRIMARY KEY,
|
---|
75 | calories VARCHAR (255),
|
---|
76 | user_id INTEGER REFERENCES User(user_id),
|
---|
77 | meal_name VARCHAR (255)
|
---|
78 | );
|
---|
79 |
|
---|
80 | CREATE TABLE Payment(
|
---|
81 | user_id INTEGER REFERENCES User(user_id),
|
---|
82 | payement_id serial PRIMARY KEY,
|
---|
83 | payment_date DATE;
|
---|
84 | );
|
---|