Postgresql Database Schema - arleenpandher/Herozon GitHub Wiki
users
| column name | data type | details |
|---|---|---|
id |
integer | not null, primary key |
username |
string | not null, indexed, unique |
| string | not null, indexed, unique | |
| password_digest | string | not null |
| session_token | string | not null, indexed, unique |
| 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 products
- has many reviews
reviews
| column name | data type | details |
|---|---|---|
| id | integer | not null, primary key |
| user_id | integer | not null, indexed |
| product_id | integer | not null, indexed |
| title | string | not null |
| body | string | not null |
| rating | integer | not null |
| created_at | datetime | not null |
| updated_at | datetime | not null |
- index on user_id
- index on product_id
transactions
| column name | data type | details |
|---|---|---|
| id | integer | not null, primary key |
| user_id | integer | not null, indexed |
| product_id | integer | not null, indexed |
| created_at | datetime | not null |
| updated_at | datetime | not null |
- index on user_id
- index on product_id
carts
| column name | data type | details |
|---|---|---|
| id | integer | not null, primary key |
| user_id | integer | not null, indexed |
| product_id | integer | not null, indexed |
| purchased | boolean | not null |
| created_at | datetime | not null |
| updated_at | datetime | not null |
products
| column name | data type | details |
|---|---|---|
| id | integer | not null, primary key |
| title | string | not null |
| description | string | not null |
| service_id | integer | not null |
| image | url | not null |
| created_at | datetime | not null |
| updated_at | datetime | not null |
service
| column name | data type | details |
|---|---|---|
| id | integer | not null, primary key |
| title | string | not null |
| image | url | not null |
| created_at | datetime | not null |
| updated_at | datetime | not null |