title: Sequelize associating two tables
body: <p>I'm quite new in Sequelize. I've been using MongoDB with Express apps and for the sake of curiosity decided to try relational database with Express project. I used sequelize ORM for modeling my data. I have two models so far. Products and Reviews. Definitely it's 1:Many relationship. So this is my Product model:</p>
  <pre><code>const {Sequelize, Model, DataTypes} = require('sequelize')
  const {sequelize} = require('../db/config')
  const { Review } = require('./review')
  
  class Product extends Model{
      
  }
  
  Product.init({
      product_id:{
          type: DataTypes.UUID,
          defaultValue: Sequelize.UUIDV4,
          primaryKey: true,
          allowNull: false
      },
      p_name:{
          type: DataTypes.STRING,
          allowNull: false
      },
      p_description:{
          type: DataTypes.STRING,
          allowNull: true
      },
      p_quantitiy:{
          type: DataTypes.INTEGER,
          allowNull: false
      },
      product_cost:{
          type: DataTypes.FLOAT,
          allowNull: false
      },
      product_price:{
          type: DataTypes.FLOAT,
          allowNull: false
      }
  },
  {
      sequelize,
      modelName: 'Products'
  })
  Product.hasMany(Review, {onDelete: 'cascade'})
  module.exports = {Product}
  </code></pre>
  <p>and following is review model</p>
  <pre><code>const {Sequelize, Model, DataTypes} = require('sequelize')
  const {sequelize} = require('../db/config')
  
  class Review extends Model{}
  
  Review.init({
      _id: {
          type: DataTypes.UUID,
          primaryKey: true,
          allowNull: false,
          defaultValue: Sequelize.UUIDV4
      },
      body:{
          type: DataTypes.TEXT,
          allowNull: false
      },
      rating:{
          type: DataTypes.SMALLINT,
          allowNull: false
      }
      
  },{
      sequelize,
      modelName: &quot;Review&quot;
  })
  module.exports = {Review}
  </code></pre>
  <p>I have used <code>Product.hasMany(Review, {onDelete: 'cascade'})</code> to build the relationship and it's working <strong>JUST FINE!</strong>
  However I have come across many Q&amp;As and also official <a href="https://sequelize.org/master/manual/assocs.html#implementation-2" rel="nofollow noreferrer">docs</a> of sequelize saying that I needed to use <code>Review.belongTo(Product)</code> as well in order to build the relationship. But when I try to use it NodeJS complained about circular dependency. Do I really have to use <code>Review.belongTo(Product)</code> too when I already have <code>Product.hasMany(Review, {onDelete: 'cascade'})</code> and working really fine?</p>