Skip to content

Database Schema

Lema El-Sherbiny edited this page Jul 26, 2021 · 10 revisions

Users

column name data type details key
id integer NOT NULL PK
username string NOT NULL
email string NOT NULL, UNIQUE
hashedPassword string NOT NULL
created_at timestamp NOT NULL
updated_at timestamp NOT NULL

Sequelize Associations

  • User.hasMany(models.Registration, { foreignKey: 'userId'});

Registration

column name data type details key
id integer NOT NULL PK
eventId integer NOT NULL FK
userId integer NOT NULL FK
ticketNum integer NULL
created_at timestamp NOT NULL
updated_at timestamp NOT NULL

Sequelize Associations

  • Registration.belongsTo(models.Event, { foreignKey: 'eventId'});
  • Registration.belongsTo(models.User, { foreignKey: 'userId'});

Event

column name data type details key
id integer NOT NULL PK
name string NOT NULL
time string NOT NULL
detail text NOT NULL
ticketPrice decimal NOT NULL
location string NOT NULL PK
pic string NOT NULL PK
userId integer NOT NULL FK
categoryId integer NOT NULL FK
created_at timestamp NOT NULL
updated_at timestamp NOT NULL

Sequelize Associations**

  • Event.belongsTo(models.Category, { foreignKey: 'categoryId'});
  • Event.hasMany(models.Registration, { foreignKey: 'eventId'});
  • Event.belongsToMany(models.User);

Category (future implementation)

column name data type details key
id integer NOT NULL PK
category string NULL
created_at timestamp NOT NULL
updated_at timestamp NOT NULL

Sequelize Associations

  • Category.hasMany(models.Event, { foreignKey: 'categoryId'});

Bookmarks

column name data type details key
id integer NOT NULL PK
eventId integer NULL
userId integer NULL
created_at timestamp NOT NULL
updated_at timestamp NOT NULL

Clone this wiki locally