-
Notifications
You must be signed in to change notification settings - Fork 0
/
data.sql
52 lines (43 loc) · 1.17 KB
/
data.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
DROP DATABASE IF EXISTS Platform;
create database Platform;
use Platform;
create table User (
userID int primary key auto_increment,
username varchar(25) unique not null,
password varchar(25) not null
);
create table Stocks (
stockID int primary key auto_increment,
stockName varchar(25) unique not null,
sector varchar(25),
unitPrice float
);
create table Transactions (
transactionID int primary key auto_increment,
userID int,
stockName varchar(25),
units int not null,
totalValue float,
transacted datetime,
foreign key (userID) references User (userID),
foreign key (stockName) references Stocks (stockName)
);
create table WatchList (
userID int,
stockName varchar(25),
foreign key (userID) references User (userID),
foreign key (stockName) references Stocks (stockName),
primary key(userID, stockName)
);
create table Discussion(
userID int,
message varchar(200),
posted datetime,
foreign key (userID) references User (userID)
);
create table StockPrice(
stockName varchar(25) ,
time datetime ,
Price float ,
foreign key (stockName) references Stocks (stockName)
);