Developer654079525's avatar

Foreign keys

Must foreign keys be constrained or would a simple unsignedBigInteger type suffice when defining relationships?

0 likes
2 replies
Glukinho's avatar

Not must, but should, I would say. Highly recommended. There are plenty of applications live normally without database constraints.

When app complexity and data volume grow database constraints bring more and more benefit, not allowing your app to have inconsistent data and related errors.

2 likes
bestmomo's avatar

Using the unsignedBigInteger type is only about the column's ability to store the data, while using a foreign key constraint is about ensuring the data is correct and related. I think it's always better to use the foreign key constraint.

1 like

Please or to participate in this conversation.