I understand that an Actice record is based on an object-relational mapping (ORM) pattern described by Martin Fowler in his book "Structure of Enterprise Application Architecture" (Addison-Wesley, 2002); which states that there is a one-to-one mapping relationship between the database record and the object representing it in the object-oriented program (OOP). When Rails creator David Heinmeyer tried to implement ORM for his Rails framework, he based it on the Fowler pattern.
In this case, ActiveRecord assigns a surrogate primary key for each table using the "ID" naming convention, and if so, why? The reason I'm asking is that it seems to make sense to assign a surrogate primary key using the naming convention "tablename_ID"; since it actually appears when creating ActiveRecord foreign keys. Also, is it possible to override the default configuration and assign a surrogate primary key using the naming convention "tablename_ID"; the reason is that especially in the case of primary keys, it seems a good idea not to use a shared name, since it is impossible to talk about the difference between the two column identifiers simply by looking at the column names: ID, ID, ID. As an example of using where this appears, there would be a problem if I export data to one table from two tables, there will be two columns with an identification name; when I import this document with updates, it would seem that there is no way to map the default identifier columns.
ruby-on-rails activerecord naming-conventions orm
blunders
source share