Skip to content

Database Schema

Dre edited this page Mar 2, 2021 · 3 revisions

Schema for PostgresQL using Flask SQLAlchemy ORM

Wine Party Database Schema

Users

Attribute Name Attribute Type Constraints
id int not null, primary key
firstName string not null, 50 chars or less
lastName string not null, 50 chars or less
zipCode int not null, 9 chars or less
description string 300 chars or less
profileImage string
email string not null, unique, 255 chars or less
phoneNumber int unique, 50 chars or less
hashedPassword string not null
createdAt datetime not null

Model Relationships:

  • User hasMany events
  • User hasMany hosts
  • User hasMany reviews

Hosts

Attribute Name Attribute Type Constraints
id int not null, primary key
firstName string not null, 50 chars or less
lastName string not null, 50 chars or less
zipCode int not null, 9 chars or less
description string 300 chars or less
profileImage string
sommelier boolean not null
mixologist. boolean not null
email string not null, unique, 255 chars or less
phoneNumber int unique, 50 chars or less
hashedPassword string not null
createdAt datetime not null

Model Relationships:

  • Host hasMany events
  • Host hasMany users
  • Host hasMany reviews

UserHost

Attribute Name Attribute Type Constraints
id int not null, primary key
favStatus boolean not null, defaults false
userId int not null, references Users table
hostId int not null, references Hosts table

Model Associations

  • This is the User - Host join table

Reviews

Attribute Name Attribute Type Constraints
id int not null, primary key
reviewText text
hostId int not null, references Hosts table
userId int not null, references Users table
rating int not null, 1 - 5
comment string not null, 300 chars or less
createdAt datetime not null

Model Associations:

  • Review belongsTo User
  • Review belongsTo Host

Other details

  • rating frontend representations in form of "fontawesome wine bottle"

Clone this wiki locally