Ф2: script2.2.sql

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