4 ms·
Two points, if your DB schema doesn't model your domain correctly you're doing it wrong to start with. And two, views are typically used to decouple the raw dat
by tensor 7y ago
Two points, if your DB schema doesn't model your domain correctly you're doing it wrong to start with. And two, views are typically used to decouple the raw database tables from whatever you want to expose to others, be those other developers or in this case external API users.
Modelling databases this way has fallen out of favour for various reasons, but it becomes extremely useful and relevant again with systems like Hasura.
- moehm 7y agoWhat's the problem with views?
- tensor 7y agoYou can't insert/update/delete data in views in all cases, and they can make debugging performance more challenging, but otherwise nothing. I think they are underused. I rarely see people using views at all, let alone using them as a test aid (composing big queries from smaller more easily tested views), or using them to define interfaces to an internal data model.
- miles-po 7y agoFor the most part, you can insert/update/delete. See: INSTEAD OF triggers. That is unless you're using MySQL/MariaDB, in which case views are the least of your worries.