-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProjPart2bc.txt
112 lines (83 loc) · 2.11 KB
/
ProjPart2bc.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
OUT OF DATE
create table Person
(username VARCHAR(20),
password VARCHAR(20),
first_name VARCHAR(20),
last_name VARCHAR(20),
email VARCHAR(20),
primary key(username)
);
create table Photo
(pID INT,
posterUsername VARCHAR(20),
postingDate DATETIME,
filePath VARCHAR(20),
allFollowers BOOLEAN,
caption VARCHAR(20),
primary key(pID,posterUsername),
foreign key(posterUsername)
references Person(username)
);
create table FriendGroup
(groupName VARCHAR(20),
creatorUsername VARCHAR(20),
description VARCHAR(20),
primary key(groupName,creatorUsername),
foreign key(creatorUsername)
references Person(username)
);
create table Follow
(followerUsername VARCHAR(20),
followeeUsername VARCHAR(20),
followStatus BOOLEAN,
primary key(followerUsername,followeeUsername),
foreign key(followerUsername)
references Person(username),
foreign key(followeeUsername)
references Person(username)
);
create table Tag
(pID INT,
taggedUsername VARCHAR(20),
tagStatus BOOLEAN,
primary key(pID,taggedUsername),
foreign key(pID)
references Photo(pID),
foreign key(taggedUsername)
references Person(username)
);
create table Reaction
(pID INT,
reactorUsername VARCHAR(20),
reactionTime DATETIME,
comment VARCHAR(20),
emoji VARCHAR(20),
primary key(pID,reactorUsername),
foreign key(pID)
references Photo(pID),
foreign key(reactorUsername)
references Person(username)
);
create table GroupMember
(groupName VARCHAR(20),
creatorUsername VARCHAR(20),
memberUsername VARCHAR(20),
primary key(groupName,creatorUsername,memberUsername),
foreign key(groupName,creatorUsername)
references FriendGroup(groupName,creatorUsername),
foreign key(memberUsername)
references Person(username)
);
create table Share
(pID INT,
groupName VARCHAR(20),
creatorUsername VARCHAR(20),
primary key(pID,groupName,creatorUsername),
foreign key(pID)
references Photo(pID),
foreign key(groupName,creatorUsername)
references FriendGroup(groupName,creatorUsername)
);
SELECT DISTINCT pID
FROM GroupMember NATURAL JOIN FriendGroup NATURAL JOIN Share
WHERE memberUsername='Ann'