-
Notifications
You must be signed in to change notification settings - Fork 0
Schema
HammadKhalid101 edited this page Mar 22, 2021
·
22 revisions
Column Name | Data Type | Details |
---|---|---|
id |
integer | not null, primary key |
first_name |
string | not null |
last_name |
string | not null |
username |
string | not null, indexed, unique |
email |
string | not null, indexed, unique |
password_digest |
string | not null |
session_token |
string | not null, indexed, unique |
buying_power |
integer | |
created_at |
datetime | not null |
updated_at |
datetime | not null |
- index on
username, unique: true
- index on
email, unique: true
- index on
session_token, unique: true
-
has_many :assets
association withassets
table onuser_id
-
has_many :owned_stocks
throughassets
-
has_many :watchlists
association withwacthlists
table onuser_id
Column Name | Data Type | Details |
---|---|---|
id |
integer | not null, primary key |
name |
string | not null, indexed, unique |
tikr |
string | not null, indexed, unique |
last_price |
decimal | not null |
percentage_change |
decimal | not null |
created_at |
datetime | not null |
updated_at |
datetime | not null |
- index on
name, unique: true
- index on
tikr, unique: true
-
has_many :assets
association withassets
table onstock_id
-
has_many :owners
throughassets
sourceowner
Column Name | Data Type | Details |
---|---|---|
id |
integer | not null, primary key |
user_id |
integer | not null |
stock_id |
integer | not null |
quantity |
integer | not null |
avg_price |
integer | not null |
created_at |
datetime | not null |
updated_at |
datetime | not null |
-
user_id
referencesusers
-
stock_id
referencesstocks
-
belongs_to :owner
association withusers
table onuser_id
-
belongs_to :stocks
association withstocks
table onstock_id
Column Name | Data Type | Details |
---|---|---|
id |
integer | not null, primary key |
title |
string | not null |
user_id |
integer | not null |
created_at |
datetime | not null |
updated_at |
datetime | not null |
-
user_id
referencesusers
-
belongs_to :user
association withusers
table onuser_id
-
has_many :watchlists
association withwacthlist_joins
onwatchlist_id
-
has_many :stocks
throughwatchlists
Column Name | Data Type | Details |
---|---|---|
id |
integer | not null, primary key |
watchlist_id |
integer | not null |
stock_id |
integer | not null |
created_at |
datetime | not null |
updated_at |
datetime | not null |
-
watchlist_id
referenceswatchlist
-
stock_id
referencesstocks