-
Notifications
You must be signed in to change notification settings - Fork 0
/
Database_Defination.txt
86 lines (77 loc) · 2.45 KB
/
Database_Defination.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
-- Define ENUM types
CREATE TYPE UserType AS ENUM ('Admin', 'Company', 'Athlete');
CREATE TYPE GenderType AS ENUM ('Male', 'Female', 'Other');
CREATE TYPE OfferStatus AS ENUM ('Pending', 'Accepted', 'Declined', 'Counter-offered');
CREATE TYPE SportsCategoryType AS ENUM ('Basketball', 'Football', 'Soccer');
-- AppUser Table
CREATE TABLE AppUser (
UserID SERIAL PRIMARY KEY,
Username VARCHAR(50) UNIQUE NOT NULL,
Password VARCHAR(50) NOT NULL,
UserType UserType NOT NULL,
Email VARCHAR(100) UNIQUE NOT NULL
);
-- Profile Table
CREATE TABLE Profile (
ProfileID SERIAL PRIMARY KEY,
UserID INTEGER REFERENCES AppUser(UserID),
FullName VARCHAR(100),
Bio TEXT,
ProfilePicture TEXT,
VerifiedStatus BOOLEAN DEFAULT FALSE,
UNIQUE (UserID)
);
-- College Table
CREATE TABLE College (
CollegeID SERIAL PRIMARY KEY,
CollegeName VARCHAR(100) NOT NULL UNIQUE
);
-- AthleteProfile Table
CREATE TABLE AthleteProfile (
AthleteProfileID SERIAL PRIMARY KEY,
ProfileID INTEGER REFERENCES Profile(ProfileID),
Gender GenderType,
SportsCategory SportsCategoryType,
CollegeID INTEGER REFERENCES College(CollegeID),
UNIQUE (ProfileID)
);
-- CompanyProfile Table
CREATE TABLE CompanyProfile (
CompanyProfileID SERIAL PRIMARY KEY,
ProfileID INTEGER REFERENCES Profile(ProfileID),
CompanyName VARCHAR(100) NOT NULL,
CompanyLogo TEXT,
UNIQUE (ProfileID)
);
-- Message Table
CREATE TABLE Message (
MessageID SERIAL PRIMARY KEY,
SenderID INTEGER REFERENCES AppUser(UserID),
ReceiverID INTEGER REFERENCES AppUser(UserID),
Content TEXT,
Timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- Offer Table
CREATE TABLE Offer (
OfferID SERIAL PRIMARY KEY,
CompanyID INTEGER REFERENCES CompanyProfile(CompanyProfileID),
AthleteID INTEGER REFERENCES AthleteProfile(AthleteProfileID),
Details TEXT,
Status OfferStatus DEFAULT 'Pending'
);
-- Watchlist Table
CREATE TABLE Watchlist (
WatchlistID SERIAL PRIMARY KEY,
CompanyID INTEGER REFERENCES CompanyProfile(CompanyProfileID),
AthleteID INTEGER REFERENCES AthleteProfile(AthleteProfileID),
SportsCategory SportsCategoryType
);
--Sponsorship Table
CREATE TABLE Sponsorship (
SponsorshipID SERIAL PRIMARY KEY,
CompanyID INTEGER REFERENCES CompanyProfile(CompanyProfileID),
AthleteID INTEGER REFERENCES AthleteProfile(AthleteProfileID),
StartDate TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
EndDate TIMESTAMP,
Details TEXT
);