Database Schema - RobertVogue/Passport GitHub Wiki

Database Schema

Users

Attribute Name Attribute Type Constraints
id integer Primary Key, Not Null
user_name varchar Not Null, Unique, 20 chars or less
display_name varchar Not Null, 30 chars or less
email varchar Not Null, Unique, 50 chars or less
hashed_password string.binary Not Null
createdAt datetime Not Null
updatedAt datetime Not Null

Model Associations:

  • Unique index on [user_name, display_name, email]
  • Sequelize hasMany Passport association.

Passports

Attribute Name Attribute Type Constraints
id integer Primary Key, Not Null
name varchar not null, 30 chars or less
user_id integer Foreign Key, Not Null
passport_status string Not Null
createdAt datetime Not Null
updatedAt datetime Not Null

Model Associations:

  • user_id references Users table.
  • Sequelize hasMany Stamps association
  • Sequelize belongsTo Users association

Stamps

Attribute Name Attribute Type Constraints
id integer Primary Key, Not Null
passport_id integer Foreign Key, Not Null
countries_id integer Foreign Key, Not Null
tags_id integer Foreign Key, Not Null
name varchar Not Null, 30 chars or less
detailed_location string Not Null
dates datetime Not Null
price string Not Null
review text Not Null
rating integer Not Null
createdAt datetime Not Null
updatedAt datetime Not Null

Model Associations:

  • passport_id references Passports table.
  • countries_id references Countries table.
  • tags_id references Stamps_Tags table.
  • Sequelize belongsTo Passports association.
  • Sequelize belongsTo Countries association.
  • Sequelize belongsTo Stamps_Tags association.

Countries

Attribute Name Attribute Type Constraints
id integer Primary Key, Not Null
name string Not Null, Unique
createdAt datetime Not Null
updatedAt datetime Not Null

Model Associations:

  • Sequelize hasMany Stamps association.

Stamp Tags

Attribute Name Attribute Type Constraints
id integer Primary Key, Not Null
name varchar Not Null
createdAt datetime Not Null
updatedAt datetime Not Null

Model Associations:

  • Sequelize hasMany Stamps association.

Diagram Visual