News for hackers. Stuff that matters.
Re:Old, Good Database Design by talaketu on Monday September 14, 2020 @06:34PM (#24475919)
How do you model "postal address"? Some postal addresses are PO Boxes, some are street addresses, etc. There are canonical representations of these different cases. Do we just shove it all in a string, and let the application perform domain validation?
Re:Old, Good Database Design by bleepblorp on Monday September 14, 2020 @08:35PM (#24476698)
Don't even try to do validation on postal addresses. The postal system has so many corner cases that you'll never be able to correctly handle all of them. Every mishandled corner case will cost you, or your counter-party, time and money.

Just dump addresses into a unicode string and let the postal system figure it out.

Re:Old, Good Database Design by gfody on Monday September 14, 2020 @08:08PM (#24476557)
postal address is one of those cases where you probably do just want to shove it all in a string as most structural constraints eventually backfire - especially if you support international: http://www.columbia.edu/~fdc/postal/

the most common schema I've seen is usually something like line1, line2, line3, city, state, country, zip, etc. if it's a reporting database then city/state/country/zip is often mashed into some sort of location id.

Re:Old, Good Database Design by outadoc on Tuesday September 15, 2020 @03:14AM (#24478652)
Watch out for `state` as well, please don't make it mandatory like so many websites. No, a region is not the equivalent of a state in France, you don't need it for my package to get there!
Re:Old, Good Database Design by cgh on Monday September 14, 2020 @07:05PM (#24476155)
Each type of postal address is a separate column. New postal address "types" would get new columns. This works particularly well when addresses can have both PO boxes as well as street addresses. This is actually more flexible than tagged unions/sum types, at least for this particular case.
Re:Old, Good Database Design by DaiPlusPlus on Monday September 14, 2020 @07:28PM (#24476298)
So a PO Box address or a house address would be concatenated into a string value and then stored in either Addresses.POBoxAdress or Addresses.House? It’s still not structured. How can someone easily get the postal-code/zip-code?