4 ms·
What I really don't get is why we don't just expose SQL directly at this point. Is it just security? Database servers have fairly extensive authentication and a
by int_19h 5y ago
What I really don't get is why we don't just expose SQL directly at this point. Is it just security? Database servers have fairly extensive authentication and authorization models.
- tored 5y agoJust give the end user an account to phpMyAdmin. Done. No complex frontend framework required.
- littlecranky67 5y agoYou wouldn't belive how often companies use excel with external datasources like this. Excel basically is the common-ui for a lot of people. And most of the projects I worked on in my professional career as a webdev, were replacing such workflow with a proper web application, because excel does not scale and eventually people fuckup their data.
- qw 5y agoEven if you solve the security issue, a query can easily bring down the server if it has a complex join query. This could be solved by only exposing stored procedures, but that just moves the code to the database server instead of the REST service with the same problems as before.
- tored 5y agoYou can also use a VIEW. How does GraphQL make sure to respect table indexes? If not you get a super slow query.
- qw 5y agoYou can still get performance issues with a view if you "select *" on a large amount of data, or join with other views. By exposing the SQL to a web page, you also open up for DDoS attacks more easily, as you can write complex SQL queries You can get the same problems with GraphQL or stored procedures too of course, if the queries are not optimized correctly
- tekknik 5y agoBecause a human is writing the resolvers pulling the data from the database. Set whatever index you want to use.
- littlecranky67 5y agoAuthorization & access restrictions. Yes, you can go quite far with table/row/column permissions, but a lot of business logic cannot be modeled using just those (i.e. "user cannot place orders if total outstanding invoice payments surpass value $X").
- int_19h 5y agoThen why aren't we working on improving the databases to allow for such complex rules, and instead wrap it in another layer (often multiple) to do all this stuff there?
- littlecranky67 5y agobecause a database should not hold your business logic. It should hold your data, and that it can do well. See also my other post on parent for more reasoning.
- funcDropShadow 5y agoI beg to differ in many interesting cases, we put at least some parts of the business logic into the database. The table design is a direct consequence of the business logic, the same is true for constraints and triggers.
- int_19h 5y agoWhy shouldn't it? As noted above, database servers already have most of this (security) logic in them - likely tested much better than whatever you can write on top of the database yourself. And given how many apps are basically just CRUD, why reinvent the wheel every time?
- yencabulator 5y agoMostly because the tooling is so bad. Or do you have unit tests, lint, and easy version control for your stored procedures? Are they written in a way that matches at all what rest of your programming is? Can you import a randomly picked utility library?