title: Sequelize Model Relationship
body: <p>I have 2 models here -</p>
  
  <p><strong>user.js</strong></p>
  
  <pre><code>module.exports = (sequelize, DataType) =&gt; {
  
    const User = sequelize.define('user', {
      id: {
        autoIncrement: true,
        primaryKey: true,
        type: DataType.INTEGER
      },
      username: {
        type: DataType.STRING,
        unique: true,
        validate: {
          len:
            { args: [4, 20], msg: "Username should be contain 4-20 characters." },
          isAlphanumeric:
            { msg: "Only letters and numbers are allowed" }
        }
      },
      email: {
        type: DataType.STRING,
        unique: true,
        validate: {
          isEmail:
            { msg: "Provide proper email" }
        }
      },
      password: DataType.STRING,
      emailverified: DataType.BOOLEAN
    });
  
    User.associate = function (models) {
      // associations can be defined here
    };
  </code></pre>
  
  <p><strong>userprofile.js</strong></p>
  
  <pre><code>module.exports = (sequelize, DataTypes) =&gt; {
    var userprofile = sequelize.define('userprofile', {
      nickName: DataTypes.STRING,
      firstName: DataTypes.STRING,
      middleName: DataTypes.STRING,
      lastName: DataTypes.STRING,
      gender: DataTypes.INTEGER,
      age: DataTypes.INTEGER,
      country: DataTypes.INTEGER,
      steamUrl: DataTypes.STRING,
      city: DataTypes.INTEGER,
      status: DataTypes.STRING
    }, {});
    userprofile.associate = function (models) {
      // associations can be defined here
    };
    return userprofile;
  };
  </code></pre>
  
  <p>Can someone give an example on how to set 1: N relationship from <strong>user</strong> to <strong>userprofile</strong> i.e, 1 <strong>user</strong> can have N number of <strong>userprofiles</strong> and also by creating this relationship will a record be auto-generated under <strong>userprofiles</strong> table whenever a <strong>user</strong> is created?</p>
  
  <p>Thank you</p>