-
Notifications
You must be signed in to change notification settings - Fork 0
/
VirtualIdentity.sql
126 lines (109 loc) · 3.23 KB
/
VirtualIdentity.sql
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
113
114
115
116
117
118
119
120
121
122
123
124
125
DROP DATABASE IF EXISTS VirtualIdentity;
CREATE DATABASE VirtualIdentity;
USE VirtualIdentity;
CREATE TABLE users(
userId int NOT NULL UNIQUE AUTO_INCREMENT,
firstName varchar(60) NOT NULL,
lastName varchar(100),
username varchar(200) NOT NULL UNIQUE,
password varchar(32) NOT NULL,
gender ENUM("M","F") NOT NULL,
dob date,
image VARCHAR(100) DEFAULT "placeHolder.jpg",
bio text,
contact VARCHAR(20),
email VARCHAR(200),
lastonline datetime,
PRIMARY KEY (userId));
CREATE TABLE interests(
userId int NOT NULL,
interests varchar(40),
FOREIGN KEY (userId) REFERENCES users(userId),
PRIMARY KEY (userId,interests));
CREATE TABLE eduQual(
userId int NOT NULL,
degree varchar(30) NOT NULL,
field varchar(70) NOT NULL,
institute varchar(200) NOT NULL,
FOREIGN KEY (userId) REFERENCES users(userId));
CREATE TABLE work(
userId INT NOT NULL,
duration VARCHAR(50),
post VARCHAR(100),
company VARCHAR(100),
FOREIGN KEY (userId) REFERENCES users(userId));
CREATE TABLE location(
userId int NOT NULL,
tag ENUM("lived","current"),
city varchar(20),
state varchar(40),
country varchar(50),
FOREIGN KEY (userId) REFERENCES users(userId));
CREATE TABLE socialMedia(
accId int NOT NULL UNIQUE AUTO_INCREMENT,
site varchar(30) NOT NULL,
firstName varchar(100),
lastName varchar(200),
username varchar(200) NOT NULL,
password varchar(20) NOT NULL,
mode enum("private","public") DEFAULT "public",
type enum("personal","business") DEFAULT "personal",
media VARCHAR(200) DEFAULT "placeImage.png",
bio text,
CONSTRAINT acc_unique UNIQUE (site,username),
PRIMARY KEY (accId));
CREATE TABLE userAcc(
userId int NOT NULL,
accId int NOT NULL UNIQUE,
FOREIGN KEY (accId) REFERENCES socialMedia(accId),
FOREIGN KEY (userId) REFERENCES users(userId),
PRIMARY KEY (accId));
CREATE TABLE posts(
postId int NOT NULL UNIQUE AUTO_INCREMENT,
text varchar(200),
media VARCHAR(200),
timestamp timestamp NOT NULL,
location varchar(100),
likes int NOT NULL,
shares int NOT NULL,
comments int NOT NULL,
PRIMARY KEY(postId));
CREATE TABLE accPost(
accId int NOT NULL,
postId int NOT NULL UNIQUE,
FOREIGN KEY (accId) REFERENCES socialMedia(accId),
FOREIGN KEY (postId) REFERENCES posts(postId),
PRIMARY KEY (postId));
CREATE TABLE messages(
msgId int NOT NULL UNIQUE AUTO_INCREMENT,
participantId int NOT NULL,
content text NOT NULL,
site VARCHAR(30) NOT NULL,
timestamp datetime NOT NULL,
msgTag ENUM("sent","received") NOT NULL,
PRIMARY KEY (msgId));
CREATE TABLE accMsg(
msgId int NOT NULL UNIQUE,
accId int NOT NULL,
FOREIGN KEY (accId) REFERENCES socialMedia(accId),
FOREIGN KEY (msgId) REFERENCES messages(msgId),
PRIMARY KEY (msgId));
CREATE TABLE accBlock(
accId int NOT NULL,
blockId int NOT NULL,
timestamp datetime,
FOREIGN KEY (accId) REFERENCES socialMedia(accId),
FOREIGN KEY (blockId) REFERENCES socialMedia(accId),
PRIMARY KEY (accId,blockId));
CREATE TABLE accFol(
accId int NOT NULL,
folId int NOT NULL,
timestamp datetime,
FOREIGN KEY (folId) REFERENCES socialMedia(accId),
FOREIGN KEY (accId) REFERENCES socialMedia(accId),
PRIMARY KEY (accId,folId));
CREATE TABLE search(
userId int NOT NULL UNIQUE AUTO_INCREMENT,
content VARCHAR(500) NOT NULL,
timestamp datetime DEFAULT NOW(),
PRIMARY KEY (userId,content,timestamp));