4 ms·
Jup I recommend creating [Postgres domains] for everything that is not specifically already a Postgres type. Want to store an order id create a OrderId domain.
by callesgg 12y ago
Jup I recommend creating [Postgres domains] for everything that is not specifically already a Postgres type.
Want to store an order id create a OrderId domain.
Want to store weight create a gram domain.
Want to store quantity create a quantity domain.
That way it becomes much more easy to spot logical errors and maintain data consistency.
Also one can use it to create something like an auto ORM.
[A domain Is like a user defined child type of the system types that can have some extra restrictions.]
- NoMoreNicksLeft 12y agoThey already have a quantity domain... it's called "integer". While I agree that domains are important and should be utilized, I hope your examples are exaggerations.
- ericcholis 12y agoI love the idea of domains, but quantity does seem to be a poor use case.
- joevandyk 12y agoYou could use use a domain to ensure a quantity can't be less than zero.
- NoMoreNicksLeft 12y agoThis is also called "unsigned int". Postgres has those.
- callesgg 12y agoI guess quantity was a poor example but I would disagree about it being the same as integer. And integer is a hole number. Nothing else can be inferred from knowing that something is a integer.