title: Multiple foreign keys on sequelize (one-to-many or many-to-many)?
body: <p>I have two tables: users and alerts. Users should be able to upvote and downvote on alerts.</p>
  
  <p>My models are defined like that:</p>
  
  <p>Alert</p>
  
  <pre><code>module.exports = function(sequelize, DataTypes) {
      var Alert = sequelize.define("alert", {
          ID: { type: DataTypes.BIGINT(11).UNSIGNED, primaryKey: true, autoIncrement: true },
          title: DataTypes.STRING,
          alert_type: DataTypes.INTEGER
      },
      {
          classMethods: {
              associate: function(models) {
                  Alert.belongsTo(models.user, {
                      onDelete: "CASCADE",
                      foreignKey: {
                          allowNull: false
                      }
                  });
              }
          }
      });
      return Alert;
  };
  </code></pre>
  
  <p>User</p>
  
  <pre><code>module.exports = function(sequelize, DataTypes) {
      var User = sequelize.define("user", {
          ID: { type: DataTypes.BIGINT(11).UNSIGNED, primaryKey: true, autoIncrement: true },
          user_login: DataTypes.STRING(50),
          user_pass: DataTypes.STRING(50),
          user_email: DataTypes.STRING(50),
      },
      {
          classMethods: {
              associate: function(models) {
                  User.hasMany(models.alert);
              }
          }
       });
       return User;
  };
  </code></pre>
  
  <p>What's the way of doing it using sequelize.js and MySQL(InnoDB)?</p>
  
  <p>Should I use belongToMany() ?
  Something like :</p>
  
  <pre><code>module.exports = function(sequelize, DataTypes) {
      var AlertVote = sequelize.define("user_alert_vote", {
          ID: { type: DataTypes.BIGINT(11).UNSIGNED, primaryKey: true, autoIncrement: true },
          vote_up: DataTypes.INTEGER,
          vote_down: DataTypes.INTEGER
      },
      {
          classMethods: {
          //    belongToMany(models.alert, ...);
          //    belongToMany(models.user, ...);
          }
       });
       return AlertVote ;
  };
  </code></pre>