Database Schema - ZhiqiLinn/airVnb GitHub Wiki

Users
| Column Name |
Data Type |
Details |
| id |
String |
not null, primary key |
| username |
String(30) |
not null, unique |
| profilePic |
String |
allow null |
| email |
String |
null,unique |
| hashedPassword |
String(50) |
not null |
| createdAt |
timeStamp |
not null |
| updatedAt |
timeStamp |
not null |
- One user can hasMany listings
- One user can hasMany bookings
- One user can hasMany reviews
Listings
| Column Name |
Data Type |
Details |
| id |
integer |
not null, primary key |
| userId |
integer |
not null, unique |
| name |
string |
not null |
| about |
text |
not null |
| address |
string |
not null |
| city |
string |
not null |
| state |
string |
not null |
| price |
string |
not null |
| serviceFee |
string |
not null |
| img1 |
string |
not null |
| img2 |
string |
allow null |
| img3 |
string |
allow null |
| created_at |
timeStamp |
not null |
| updated_at |
timeStamp |
not null |
- One listing can only belongsTo one user
- One listing can hasMany bookings
- One listing can hasMany reviews
Bookings
| Column Name |
Data Type |
Details |
| id |
integer |
not null, primary key |
| userId |
integer |
not null, unique |
| listingId |
integer |
not null, unique |
| checkIn |
date |
not null |
| checkOut |
date |
not null |
| created_at |
datetime |
not null |
| updated_at |
datetime |
not null |
- One booking can only belongsTo one user
- One booking can only belongsTo one listing
Reviews (Bonus)
| Column Name |
Data Type |
Details |
| id |
integer |
not null, primary key |
| userId |
integer |
not null, unique |
| listingId |
integer |
not null, unique |
| rating |
integer |
not null |
| content |
string (1000) |
not null |
| created_at |
datetime |
not null |
| updated_at |
datetime |
not null |
- One review can only belongsTo one user
- One review can only belongsTo one listing