Re:Databases always have a schema (2018)
by _bxg1 on Monday February 25, 2019 @03:16PM
(#19249012)
You can still have an authoritative schema, it just doesn't live in the DB itself. It would have to be defined in the code, generally.
[ Parent
| on HN ]
Re:Databases always have a schema (2018)
by nathan_long on Monday February 25, 2019 @04:02PM
(#19249433)
I would argue that it's not authoritative. Nothing guarantees that the records in the db match that schema; the closest you get to a guarantee is your diligence to 1) run a job mutating all records every time you change your in-code schema and 2) ensure that nothing but your latest application code can write to the db.
OTOH, `\d users` in PostgreSQL is authoritative; there cannot be a row that does not conform to the fields, types, and constraints listed there.
> I would argue that it's not authoritative.
I think the word you're looking for is "enforced". Where there are multiple schemas, one can certainly be the "authority", even if it's not enforced across all data.
Re:Databases always have a schema (2018)
by nathan_long on Tuesday February 26, 2019 @10:10AM
(#19254843)
Whatever terminology you use, every place you loop through records doing stuff with them, you'll either have to decide what to do with oddly-shaped records or implicitly decide to let exceptions occur at that point. Whereas if PostgreSQL tells you that `user` has a `email character varying(255) NOT NULL`, you can be sure that every `user` does. The only place you need a conditional related to that is when trying to insert an invalid record.