1/7/2024 0 Comments Datagrip execution plan![]() The only remaining issue is SQL is chatty. Even if SQL had a detailed type system, therefore, most people wouldn't bother duplicating their detailed type definitions from Java to SQL or back. More subtle errors are possible, like comparing metric and imperial measures, but since SQL is often used in tandem with a system's language (Java, C++) or a script, all this domain logic is offloaded to them and their type system. ![]() ![]() The kind of mistake where you compare "weight and quantity" is not likely. Regarding the type system, type systems can always be better, but let's not forget type systems (typically) exist to eliminate mistakes, not to enable new features. There's no way to do it at the source, so complaining SQL also does it, is like shouting at clouds. This is one of the biggest issues in optimizing compilers, canonicalizing expressions so patterns can be recognized. Regarding having many ways to express the same query: that's true for all languages. Once again, SQL allows you to define a field as non-nullable, so complaining about it being there if you EXPLICITLY WANT IT is silly. So having a primitive for it makes sense. Real-world data is not perfectly "rectangular". DISTINCT is optional because the need for it is exceptional, and its cost is high.Įven you don't buy the "have no NULL" argument. An expensive step that in fact doesn't matter, because the vast majority of queries don't produce duplicate results in practice. Likewise, having SELECT DISTINCT be a default would mean a very expensive processing step in your query processing being a default. However without defining a primary key, enforcing unique rows would mean the database silently indexing the ENTIRE ROW'S CONTENTS, including potentially blobs and large text fields. SQL doesn't require primary keys because relational algebra has no such concept as a "primary key". It seems a lot of those things you list as "wrong" come from lack of understanding of the reasons behind these choices, and born out of pure idealism in vacuum.įor example, allowing duplicate rows is irrelevant, because if you have a primary key, there are no duplicate rows. It composes poorly for anything dynamic, even simple things like ordering by a column name. It's hard to dynamically build queries. SQL is quite chatty, so much so that you can omit words in some incantations. SELECT DISTINCT should have been the default instead of SELECT ALL. His example shows at least 12 ways to answer "Get part numbers for parts that either are screws or are supplied by supplier S1, or both." SQL has many ways to express the same query. Date uses the example of `p.weight = sp.qty` to show a comparison on domain types that shouldn't be allowed. For example, you can compare or join on different domain types if the base type is the same. Domain types only provide type aliases not a new type. Personally, I have trouble understanding how to support this limitation given LEFT JOIN. Tuples and therefore relations don't ever contain nulls. Real relations don't contain duplicate tuples but SQL tables allow duplicate rows. We see SQL as a kind of database COBOL, and we would like to see some other language become available as a better alternative to it. Instead, it’s the relational model that has to provide that foundation. > SQL is incapable of providing the kind of firm foundation we need for future growth and development. Chris Date wrote several books comparing SQL to a more pure implementation relational algebra, Tutorial D. ![]() Light-weight ORM like Dapper serves well, it does not abstract out the concepts of RDBM, but make things easier. Just learn it.Īctually, I'm not without ORM now a days. Please don't avoid learning about RDBM by using an ORM. So 20 years in, the ROI of learning SQL is great. There are different solutions for different scenarios, but as long as the DB chugs along, why? Sometimes it's sickening. Want to communicate between processes? Database. I still hate to compose SQL in code, but there is no better way.ĭatabases are used in every situation. When problems occur, you have to debug both.Ģ0 years in, I am still learning about RDBM. If you want to use ORM, you have to learn both SQL and ORM with some depth at least. Complexity added upon another complexity does not make a polished interface. RDBM itself is complex enough, let's put another complex abstraction above it so we can forget about the tables and columns and joins and foreign keys. No, ORM does not simplify coding! It's a big complex adapter which does not fit many cases. Writing another language in the language I am coding is wrong. I used to love ORM, I used it everywhere. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |