4 ms·
> Because some people can't stand having to work with SQL,migrations,schema and constraints The real question is “How come these people are allowed anywhere ne
by catnaroek 10y ago
> Because some people can't stand having to work with SQL,migrations,schema and constraints
The real question is “How come these people are allowed anywhere near data stores?” SQL isn't ideal, but how many of the alternatives are better at protecting the integrity of your data?
- EpicEng 10y agoThank you. Not everything is easy. This is the difference between engineering and 'hacking'. Hacking is not something to aspire to; it's something you do because of crushing, external pressures.
- 1879325237 10y agoHacking is trying to get the SQL representation into something programmers use via the way of an ORM. At the end of the day, a SQL database doesn't represent the data in a way the programmer uses the data. It has to be transformed and that is a bigger hack than loosening some constraints.
- orf 10y ago> At the end of the day, a SQL database doesn't represent the data in a way the programmer uses the data. Errrr that's exactly what they do, unless you've got a terrible schema and havent thought about your data enough. The thing is about 'sql databases' is you can use the power of sql to fetch the data in any representation you want.
- catnaroek 10y agoORMs are a really bad attempt to force a square peg into a round hole. The mismatch between the relational model and object-oriented design principles is simply too big. In the relational model: (0) A relation is a collection of tuples of primitive values. Every relation has a relation schema, which determines the arity of its tuples and the type of each tuple component. In other words, the relational model is first-order. (1) There are a few basic operators for computing relations from other relations (relational algebra). (2) There is a mathematical theory (database normalization) of how to design primitive relation schemas to avoid storing duplicate information, and running into insertion, update and deletion anomalies. On the other hand, in a pure object-oriented program: (0) An object is a collection of data and operations on it. The data is hidden from the rest of the program, so the only way to operate on it is to use the object's operations. The operations may take objects as arguments and return objects as results, so objects are intrinsically higher-order. (1) In general, there are no limits on how one can define a single object's operations. However, it's impossible to define operations which require knowledge of the internal representation of two or more objects at a time. (2) There are heuristic guidelines (e.g., SOLID principles) for designing flexible object-oriented systems. However, they lack any sort of rigorous foundation beyond “it seems to work in practice”, so object-oriented designers may deviate from these guidelines at their own discretion. --- For data-oriented applications, it's pretty clear to me that the relational model has important advantages over object-orientation: (0) The decoupling between data and operations allows the database designer to focus exclusively on data integrity constraints, instead of anticipating whatever queries users will want to make. (1) The limited expressiveness of relational algebra (with no recursively defined relations) is also a blessing, because it makes automated query optimization tractable in practice. While objects present problem after problem: (0) Object graphs are intrinsically directed, and must be traversed in the direction of its links. This makes queries less declarative. (1) Objects have a notion of identity, which destroys many opportunities for using equational reasoning to build large queries. This also makes queries less declarative. Of course, the relational model says nothing about general-purpose programming, whereas object-orientation does. But there exist other paradigms for general-purpose programming that are less badly in conflict with the relational model. For instance, functional and logic programming: (0) Don't reject the use of first-order data, decoupled from operations. (1) Prefer the notion of mathematical variable, whose meaning is given by substitution (a first-order operation), to imperative assignment, whose meaning is given by certain predicate transformers (intrinsically higher-order gadgets).
- daveguy 10y agoI was going to say I wish there was a way to bookmark single comments. Then I realized the reply page is essentially a link to a single comment: https://news.ycombinator.com/reply?id=11861520&goto=item%3Fid%3D11860725 https://news.ycombinator.com/reply?id=11861520&goto=item%3Fi... If anyone wants to bookmark this one.
- icebraining 10y agoClicking on the time ("X hours ago") gives you https://news.ycombinator.com/item?id=11861520 https://news.ycombinator.com/item?id=11861520