-
Notifications
You must be signed in to change notification settings - Fork 0
Database Schema
Kevin Bartolome edited this page Apr 28, 2022
·
18 revisions
Schema of the PostgreSQL database
+ Users Table
- Many to Many: User belongsToMany Image (fk: userId // through: "Favorite" // otherKey: imageId)
- One to Many: User hasMany Image (fk: userId)
- One to Many: User hasMany Favorite (fk: userId)
- One to Many: User hasMany Profile (fk: userId)
- One to Many: User hasMany Comment (fk: userId)
- One to Many: User hasMany Comment (fk: uploaderId)
+ Images Table
- Many to Many: Image belongsToMany User (fk: imageId // through: "Favorite" // otherKey: userId)
- Many to One: Image belongsTo User (fk: userId)
- One to Many: Image hasMany Favorite (fk: imageId)
+ Comments Table
- Many to One: Comment belongsTo User (fk: userId)
- Many to One: Comment belongsTo User (fk: uploaderId)
+ Profile Table
- Many to One: Profile belongsTo User (fk: userId)
- Favorites Table
- Join Table for User/Images
- Many to Many: Favorite belongsTo User (fk: userId)
- Many to Many: Favorite belongsTo Image (fk: imageId)
column names | data type | details |
---|---|---|
id | integer | PK, not null |
username | string(3, 256) | unique, not null |
string(3, 30) | unique, not null | |
hashedPassword | string.binary | unique, not null |
- username,
unique: true
- email,
unique: true
column names | data type | details |
---|---|---|
id | integer | PK, not null |
userId | integer | foreign key |
imageURL | string | not null |
tags | array | defaultValue = [] |
favoritedCount | integer | not null, defaultValue = 0 |
-
userId
referencesUsers
table
column names | data type | details |
---|---|---|
id | integer | PK, not null |
userId | integer | foreign key |
uploaderId | integer | foreign key |
commentText | text | not null |
-
userId
referencesUsers
table -
uploaderId
referencesUsers
table
column names | data type | details |
---|---|---|
id | integer | PK, not null |
userId | integer | foreign key |
fullName | string | not null |
location | string | not null |
avatar | string | defaultValue = "default-avatar.jpg" |
biography | text | not null |
-
userId
referencesUsers
table
column names | data type | details |
---|---|---|
id | integer | PK, not null |
userId | integer | foreign key |
imageId | integer | foreign key |
-
userId
referencesUsers
table -
imageId
referencesImages
table