I have a table of of data where the primary unique element is called a CRN, which denotes "course registration number", and it's an integer value.
In this table there are around 4000 classes, and each class has a unique CRN.
My question is, in my schema builder for migrations, should this I set the CRN as a unique, a primary, or an increments?
According to my usage, a unique makes the most sense.
The CRN is indeed unique, and never changes. I have a script that updates the other columns that corresponds to this CRN, and having CRN as unique will prevent additional rows of the same CRN created.
A bug I ran into without setting any of these constraints of unique/primary/increments is, when I re-ran my script that updates the enrollment numbers, for example, for a CRN, a new row is generated instead of it being updated. So now I have two rows of data of the same CRN.
Aucun commentaire:
Enregistrer un commentaire