1
Hi. I have this table with 3 primary keys and I need to reference it in another table. It’s like?
I was just going to put an int-type id in the monthly table to be the only primary key. But each monthly fee must be unique to a contract and have only one record per month/year, so the 3 as primary key.
In the simplest model, I would link the id that is primary key with the other table and create a foreign key, like this: id_mensalidade REFERENCES mensalidade(id)
. Right?
But how do I do it in this model?
Thanks, if it is not clear I can edit the post.
To using Mysql.
You can create a whole type primary key for the table and additionally apply a Unique Constraint to the three existing fields.
– Piovezan
I didn’t do this because I found the extra 4 bytes for each row of my table descent.
– boolean
In the case of this table, because of the low volume of data, it seems to me to have 4 bytes more or less. More important would be the clarity and simplicity of working with the simple primary key. Composite keys in general are not very encouraged.
– Piovezan