I have a user model (sql table) that has_one : profile.
profiles have user_id to refer to an user object.
Do i really need to have profile_id column ?
What are the advantages and disadvantages ?
I guess one advantage will be the size of the table that will be 1 collumn smaller.
What are the disadvantages ?
No. You don’t need id. But you need primary key, which may be other column in table. Naturally primary key means that value must be unique and not null.
Just create table without id column:
Then in model:
The table shouldn’t have autoincrement or sequencer created – just check that. The value should be set by you or by framework if you are using association method (
user.profile.create(...)) .Disadvantages: Some plugins may expect ‘id’ to be PK but this means they are poorly written.