3 ms·
I'm not porcupine, but I feel that we are definitely using relational models. The drive towards objects (and REST as well) tries to project data into a hierarch
by BlackFly 6y ago
I'm not porcupine, but I feel that we are definitely using relational models. The drive towards objects (and REST as well) tries to project data into a hierarchy. Orders belong to customers, so you nest orders under customers. But you are B2B, so you break into one market and realize that suddenly joint purchases are a thing. Suddenly you have orders with multiple customers.
If you were using a relational model for backing the orders and customers, there is no real issue. An order is just a tuple of data, a customer is just a tuple of data, the "belongingness" is just modeled via foreign key constraints. Maybe you were smart enough to already model it as many to many and you just relax a uniqueness constraint in the join table or you had no such uniqueness constraint already and it was enforced by the application. Otherwise, you move the foreign key out of the order tuple into a joining table and move on to changing the projection queries and the downstreams. If you were storing it as nested data documents... I don't know because I have never done that, but I do know the trouble with trying to invert hierarchical addresses in such cases and it is annoying and inefficient (abstraction inversion).
In a relational model, any hierarchy is a contrivance via foreign key constraints. These same attributes are easy to invert. If you have a business need for a hierarchy, that shows up in the business logic by the precise query used to project the relations along the foreign keys.
In the scope of the comment made. I find it hard to believe that someone doesn't see that we are indeed using relational models of data and I find it sad that the known benefits apparently aren't so widely known. Yes, in a concrete use case you project out the data you need and type that (map it to objects). But if you modeled the data well, as your use cases increase in number or evolve your data model often doesn't need to change as much as your business logic if you did your job well. The job being relational data modelling.
I myself use async programming, and there aren't really good ORMs for that since you don't want every single property of your object to be an async property (which most ORMs do with lazy loading).
- cmrdporcupine 6y agoYes, this is roughly what I was getting at. Relations are sets of sets, and the relationships are products of the query method, not a static property of the storage of the data. This insight by Date and Codd was a huge discovery in data management. Unfortunately SQL tended to paper over some of this beauty with its talk about "tables" with "columns", which are just one way of representing relation and tuples. I can't count the number of times I've heard someone say "but my data doesn't fit into a table", completely not getting it. That combined with the rapid rise in object-oriented programming through the 90s and early 2000s, as well as a bunch of other things I won't get into, led to many people mistreating and/or rejecting the relational database. We were taught, or taught ourselves to model our applications in an object-oriented way, and then became frustrated because we treated the database as a "datastore" rather than an information modeling and retrieval tool like it was meant. Without an understanding of relational fundamentals people repeated the same mistakes that Date and Codd were originally trying to rectify with their pioneering work on the relational database. The relational model was a response to the problems with hierarchical and network databases; to try and formalize a more flexible model, with a mathematical and logical basis. "Graph databases" and "document databases" and "object databases" _look_ more flexible from the front, but fundamentally are the opposite. They confine the kinds of relationships data can take, in advance. The object oriented model is good for representing some aspects of our world; especially, perhaps, graphical interfaces, or simulation systems. In my opinion it is inferior for the modeling of data/information itself. We need a relational renaissance.