Rails has_many :through --> Should I keep a primary key column? Rails has_many :through --> Should I keep a primary key column? ruby ruby

Rails has_many :through --> Should I keep a primary key column?


Keep it. Later on youll find the unique identifier pay off in ways that aren't obvious initially.
Unlike other agile development principles, it's better to get data quality items like this addressed up front.


If you ever have something unique to the author-book relationship, you'll need the id to set it in this table via an AuthorBook model. It doesn't sound like a likely scenario in this case, and you can add it later if you need to.


If it's has_many through that means that author_book is a active record model, so please leave id for it. But if you'll use has_and_belongs_to_many connecting table doesn't need id http://apidock.com/rails/ActiveRecord/Associations/ClassMethods/has_and_belongs_to_many