The Only Database Abstraction You Need

  Рет қаралды 10,100

CompSciGuy

CompSciGuy

8 ай бұрын

You are interacting with databases wrong. You shouldn't use ORMs even though they are the default for many instead of SQL. ORMs are bad and constrict you unnecessarily. You should prefer to use SQL and after this video you will. By using SQL you will supercharge the usability of your database. Although there are nice areas to use ORMs - like database migrations.
Also, sorry about my voice, I was a bit sick during recording :(

Пікірлер: 100
@slotos
@slotos 8 ай бұрын
> An ORM attempts to store your data in an object oriented format This one right here, officer!
@BeanCoffeeBean
@BeanCoffeeBean 7 ай бұрын
02:55 "We simply can't" well ... yes ... you can
@em_the_bee
@em_the_bee 8 ай бұрын
1:05 I don't get it. So you present an inheritance problem, argue that RDBs can't into inheritance and say that ORMs are bad because of it?.. And then what, how does pure SQL deal with the problem better? Are you implying OO-languages and ORMs can't function without creating inheritance trees in your models? Also, I'm not a fan of single table inheritance, but you could have at least mentioned it.
@zoladkow
@zoladkow 8 ай бұрын
and connection pooling as a reason for using ORM? oh gosh... should we tell him?! 🤭
@Tvde1
@Tvde1 7 ай бұрын
This video is full of false equivalences and cherry picked examples
@em_the_bee
@em_the_bee 8 ай бұрын
4:01 this is actually absurd How would a no-ORM world look like and how exactly would this problem be any different? You know nothing stops you from writing a transaction using an ORM, right?
@em_the_bee
@em_the_bee 8 ай бұрын
Just finished watching this video and had to make sure it's October, not 1st of April
@x00xii
@x00xii 8 ай бұрын
Aggreed. Those two inserts would be separate transactions by default in your average DBMS, so of course a delete statement can get in between.
@ChristianConrad
@ChristianConrad 8 ай бұрын
@@x00xii Because there's only one RDBMS in the world, or because they all work alike? There's nothing to say those statements wouldn't be wrapped in a transaction in most databases. (And if they aren't, most sensible systems can wrap them in one.)
@x00xii
@x00xii 8 ай бұрын
@@ChristianConradwe can make anything happen when we introduce assumptions. In the video he does not use transactions, and as such it is wrong to assume the execution of the two statements is one single transaction.
@notlekrut
@notlekrut 7 ай бұрын
Yeah, feels like the guy just used a bad ORM and decided to make a rant about all ORMs... some of these examples are not true at all for a lot, probably most, ORMs
@SIMULATAN
@SIMULATAN 8 ай бұрын
I think an important aspect / advantage of ORMs is type safety, not having to worry about the underlying schema, incredible ease of use and the possibility to pass data around the system without creating data classes additionally to the raw sql queries
@MrCompSciGuy
@MrCompSciGuy 8 ай бұрын
Agree on all of it except for not having to worry about the underlying schema. You'll need to worry about that anyways unless you're doing the simplest of crud stuff. But the type safety is a very good point, that's why I really like the sqlx rust crate.
@filipniklas
@filipniklas 8 ай бұрын
Yes, type safety is a big win for me too.
@marcobaldi138
@marcobaldi138 8 ай бұрын
I think the main selling point of prisma is TypeSafety which together with TRPC and/or different generators really make my life easier. Its nesting syntax is the blood price to pay.
@__a8as
@__a8as 8 ай бұрын
Orm is bloat i use chatgpt
@Daniel_Zhu_a6f
@Daniel_Zhu_a6f 8 ай бұрын
Type safety can be achieved by having a function that encapsulates query. "Incredible ease of use" is a dubious point. 10 years ago OOP was told to be the best an simplest way to program, but new languages gravitate towards plain data+functions.
@vitorguidorizzzi7538
@vitorguidorizzzi7538 7 ай бұрын
False statements: 0:03 ORM are an attempt to make SQL obsolete 0:20 its a abstraction some people use to not learn sql 0:30 cherry picks bad code to make a point 0:50 ORMs attempt to store data in OOP format (most do, but not all) 4:00 Most ORMs are not transctionally correct (idk what you even mean by that tbh, the example is just a skill issue of a developer not using transactions, which as you mentioned can be done in raw SQL)
@zimdogmail
@zimdogmail 7 ай бұрын
Exactly. It's amazing how many of these videos parrot the same statement that "ORMs are an attempt to make SQL obsolete" Transactions are always a funny one too because it's not like writing SQL magically makes you use a transaction.
@IncomingLegend
@IncomingLegend 8 ай бұрын
I highly doubt all ORMs work as you describe it...
@zeMasterRuseman
@zeMasterRuseman 7 ай бұрын
1. Create stored procedures 2. Call stored procedures It's that simple.
@satyayuga0
@satyayuga0 6 ай бұрын
Kids... Don't listen to this man
@damiantedrow3218
@damiantedrow3218 5 ай бұрын
this is the way. learn your dbms.
@ancyracademyfr
@ancyracademyfr 7 ай бұрын
ORM have been misused for years due to improper knowledge of how to architecture an application. Once you start to apply an hexagonal architecture pattern, you can concentrate database access in your DBAL (typically in Repositories) and adapt your use of the DB, either by using the ORM Query Builder or by writing raw SQL queries. ORMs shine in how they allow to map relational data to objects. If you add CQRS and separate commands from reads, you can quickly realize how you don't need an ORM on the read side but mostly on the write side.
@analisamelojete1966
@analisamelojete1966 6 ай бұрын
That’s a good point.
@FainTMako
@FainTMako 6 ай бұрын
ayy someone spoke up who appears to have an actual modern mentality! Go you!!
@RasmusFrederiksen169
@RasmusFrederiksen169 17 күн бұрын
Honestly having been forced to use ORMs at work, and also having to migrate between databases (for bad reasons, don't ask); when moving between databases, you WILL find inconsistencies in ORMs where they handle a migration set just fine in one db, but utterly fail on another engine
@em_the_bee
@em_the_bee 8 ай бұрын
All of the example at 0:31 are awful because of the code, the languages and the libraries themselves, not because of the concept of an ORM. Show these to any developer using Rails and ActiveRecord, which actually has functionality and readable queries (even in shema migrations lul), they'll laugh. For example, you don't need to .include(x => x.stuff).then_include(y => y.more_stuff), (if I understood correctly what the code does), you can do .includes(stuff: [:more_stuff, :even_more_stuff]) Whatever god awful madness is on the second screenshot isn't how anyone ever would write production code, this is for seeds/tests at best, and even then you would create each type of record in a separate statement and put them into variables to reuse in the next.
@rainerwahnsinn2150
@rainerwahnsinn2150 7 ай бұрын
Yeah I don't think that guy ever used a good ORM correctly.
@haroldcruz8550
@haroldcruz8550 Ай бұрын
@@rainerwahnsinn2150 There are no good ORM, it's always about picking the bad instead of the worst
@Sander-Brilman
@Sander-Brilman 8 ай бұрын
what is your opinion about EF core though? i learned sql before i stared using ORM's which allowed me to actually check how good the queries are it generates and its actually a pretty complete and performant ORM. (as long as you dont do stupid things ofcourse, but bad code can be written in any language)
@ChristianConrad
@ChristianConrad 8 ай бұрын
WTF is "EF core"? Are you under the impression that whatever language that belongs to is the only programming language in the world?
@shimadabr
@shimadabr 7 ай бұрын
​@@ChristianConradEF Core is Entity Framework. It's the most used ORM in the .Net ecosystem. Why are you mumbling? This is not Twitter.
@ChristianConrad
@ChristianConrad 7 ай бұрын
@@shimadabr: “Mumbling”? WHAT, SHOULD I SHOUT IN STEAD? This isn't a 3270 terminal. But thanks for the info!
@testales
@testales 7 ай бұрын
I had project some years ago where a non core version of EF was used, but I guess that's quite comparable. I liked the fluent definitions and the migrations once I got them finally running. Especially early on when the database changes a lot, it's nice to have something in place that can just update an outdated target database on connect. But overall I'd not use it again. It seemed to be nice in the beginning but the more the project grew, the more issues came apparent. A lot additional time was required to just get into the ORM specifics while SQL was common knowledge. When the structures became more complex, EF only created suboptimal SQL for that and it had to be overridden at some point because there apparently was no "high level" way, to prevent it for example from creating unnecessary or plain wrong relationsships between tables. The migration offered a rollback option but not transactional and I think transactions in general were not exactly easy to implement in a reliable fashion. Some strange errors occured due to lazy loading not functioning well when a complex UI framework was used on top of it. It required more and more debugging and adding additional attributes and handling to make sure everything was executed by the ORM as intended. The generated SQL by the ORM was overly complex and hard to understand. At the very best, I'd would say using the ORM had cost at least as much time it may have saved in first place and also resulted in the application completely dependent on it, so I'd be hard to change it.
@not_a_cool_handle
@not_a_cool_handle 7 ай бұрын
@@ChristianConrad dafuq is wrong with you
@herozero777
@herozero777 3 ай бұрын
Thanks for this video. You raised very good points which has benefitted me immensely. Your video also led to a follow-up video by thePrimeGeon netflix guy. So thanks 😊
@PurpleDaemon_
@PurpleDaemon_ 7 ай бұрын
I can't remember the last time EVERY argument in a video was wrong, but this is it.
@SPAHI43
@SPAHI43 7 ай бұрын
Totally BS video, ORMs could be pain in the ass that's true, but most of the statements are wrong if you just look at the documentation of any modern ORM
@JorgeEscobarMX
@JorgeEscobarMX 7 ай бұрын
SQL alchemy is a pain in the ass. Not because of it, but how people uses it to avoid learning or use SQL.
@Th1200
@Th1200 7 ай бұрын
PLEASE DO NOT USE THIS VIDEO FOR LEARNING; the author got so many points wrong. First: ORMs do not intend to make SQL obsolete. Most of the assumptions the author made and some of the examples are just oversimplifications, wrong or miss the point. E.g. SELECT * example just shows that the author has not really spent time exploring different ORMs for different languages; I know at least 2 ORMs for nodejs which invalidate that argument without any discussion. The transactional stuff is just completely wrong. At the end mostly the pro arguments remain which makes the conclusion just weird (connection pooling is not even something that is exclusive to ORM but mostly depends on the individual db driver). I recommend that the author reads the article "OrmHate" by Martin Fowler.
@adambickford8720
@adambickford8720 6 ай бұрын
You don't need to go hog wild on orms, a simple class that does a query and maps the result to an object is fine 99% of the time. That usually makes it trivial to copy/paste that gnarly dba query you don't understand, etc. The trouble is when you start trying to do joins and relationships 'magically'. Your updates/inserts should be as tactical as possible, not just 'throw an object graph at it and hope dirty checking works'. Sure, it'll work great in your PoC, but 3-4 years in it needs a rewrite.
@genechristiansomoza4931
@genechristiansomoza4931 7 ай бұрын
I don't see the need to use ORM because even the basic mysqli offers parametized queries that escapes strings for security.
@k98killer
@k98killer 7 ай бұрын
2:50 why are you using a "NOT LIKE" clause with a literal string instead of a pattern? It is semantically equivalent to the simpler "!=" clause unless there's something funky going on with your db engine. Same with the later "LIKE" clause. What is the point of this?
@vahanmkrtchyan2504
@vahanmkrtchyan2504 5 ай бұрын
You need to know sql anyways .Orm is great tool , if u have complex queries you will debug thus anyways and put some optimisation , ORM does not matter here. SQL != ORM . SQL BUILDER != Object Relational Mapping . Author lacks understanding this. You can write sql and use ORM to populate items.
@satyayuga0
@satyayuga0 6 ай бұрын
EF Core is my bae
@sarabwt
@sarabwt 8 ай бұрын
There is a fourth, superior option: ORM with a Query Builder like TypeORM does it. I have done a ton of complex queries, that would be simply impossible with other ORMs and a pain in the ass to implement with raw dogging SQL.
@muhwyndham
@muhwyndham 8 ай бұрын
Idk what painful about raw dogging SQL. It's easy, it's declarative, you don't care how it's done just give me what I ask. I prefer the other way around, generator that generates type safe methods from raw SQL, my favorite being sqlc
@ChristianConrad
@ChristianConrad 8 ай бұрын
WTF is "TypeORM"? Are you under the impression that whatever language that belongs to is the only programming language in the world?
@sarabwt
@sarabwt 8 ай бұрын
@@muhwyndham Unless you are doing hello world shit, it is a pain in the ass to write and maintain. I'm all for "don't care how, just do it", but ORMs are not solving that issue or at least shouldn't. All they should do is map the result into objects.
@sarabwt
@sarabwt 8 ай бұрын
@@ChristianConrad Are you under the impression that it matters which language it belongs to? I'm was about the concept and gave the library as an example. The ORM concepts in the video are lacking, because there does exist another solution, which gives you full power over SQL, while handling the object mapping for you... Is this shit really that hard to undestand?
@muhwyndham
@muhwyndham 8 ай бұрын
@@sarabwt dunno, I maintain code base with 300k loc that does not use orm at all. Does not have that much issue with it.
@filipniklas
@filipniklas 8 ай бұрын
Appreciate the video! Great stuff! I've mainly been using Prisma but there are times when a SQL query needed, and you can execute so-called "raw queries" within Prisma using SQL, but these tend to be limited to one-liners only (unless I'm mistaken), so there are definite limitations here. Your video also brought to my attention how ORMs select all data from a table, which seems hugely inefficient.
@ChristianConrad
@ChristianConrad 8 ай бұрын
@filipniklas: WTF is "prisma"? Are you under the impression that whatever language that belongs to is the only programming language in the world?
@dappermink
@dappermink 7 ай бұрын
​@@ChristianConradIt's okay to not know something, google is your friend 😉
@ChristianConrad
@ChristianConrad 2 ай бұрын
@@dappermink : 1) When @filipniklas brings up something as an example, it's up to him to explain WTF he's talking about. People can't be expected to go do a bunch of Internet searches for every utterance in a debate. 2) _"google is your friend"_ ?!? That was looong ago. If you still believe that, you've got a lot of catching up to do.
@dappermink
@dappermink 2 ай бұрын
@@ChristianConrad You are on a video about ORMs, there is a context. Most people here will know Prisma and if they don't they can always search or ask nicely. You can't expect everyone to only be talking about things you know. Should he also explain what SQL is just in case someone who doesn't know find its comment? Or where do you draw the line seriously? Also maybe his comment is targeted only to those who know Prisma already, if you don't maybe just consider that you may not be the audience
@Koroistro
@Koroistro 7 ай бұрын
Meanwhile where I work they rawdog sql while never setting up relational constraints (foreign keys are never specified as such), be amazed by 20+ year old java codebases.
@CorvinhoDoMal
@CorvinhoDoMal 7 ай бұрын
0:16 Brazil referenced
@PatrickSteil
@PatrickSteil 6 ай бұрын
I just ask GPT to build my SQL queries. Solves all the issues (if you know enough about what you want it to do)
@testales
@testales 7 ай бұрын
I had to learn the lesson of this video the hard way, I can fully agree with about everything said. Just leave database logic in the database, do not try to re-create or abstract it within your application using some kind of ORM. As stated, you also usually don't change the DBMS and if you do you'll most likely find out that ORM didn't really help because new issues will arise left and right and soon enough you'll be debugging deep into the ORM sources to figure out what is handled how and how to change your code to work arround it. Just treat your database like a webservice that exposes a certain API. So just design stored procedures for your needs and consider to return XML for complex queries. You can easily work with XML in your application and don't have to worry about database internals. You can even create XML schemas as part of your API definition. That said for simple mapping purpuses from one more or less flat object to table for store and retrieval, a ORM might be indeed a good option.
@ChristianConrad
@ChristianConrad 8 ай бұрын
1) The OO impedance[sic] problem you mention between ~0:55 and ~1:40 can probably be somewhat alleviated by building a sensible table structure in the DB first, some views on top of that, and only then importing these data structures into whatever programming language you're working with. Something like: create table person as person_id integer autoincrement primary key, -- or "generated by sequence" first_name varchar(50), last_name varchar(50), birth_date date, ... ; create table student as student_id integer autoincrement primary key, -- or "generated by sequence" person_id integer unique foreign key refers to person.person_id, university varchar(50), course varchar(50), ... ; create table graduate_student as graduate_student_id integer autoincrement primary key, -- or "generated by sequence" student_id integer unique foreign key refers to student.student_id, -- person_id integer unique foreign key refers to person.person_id, -- Maybe? Probably unnecessary. degree varchar(50), num_publications integer, ... ; create view persons as select p.person_id, p.first_name, p.last_name, p.birth_date, ... -- s.student_id, -- Maybe? Probably unnecessary. s.person_id, s.university, s.course, ... -- g.graduate_student_id, -- Maybe? Probably unnecessary. g.degree, g.num_publications, ... from person p join student s on s.person_id = p.person_id join graduate_student g on g.student_id = s.student_id -- or possibly g.person_id = p.person_id ; Then link the Person object in your code to that view, not the table(s). Will work fine for reading, and for writing if your DBMS supports insertable / updatable views. If it doesn't, inserting becomes a little hairier, having to insert into the three tables separately. 2) A nice compromise is the Delphi (and Free Pascal / Lazarus)[*] system with "raw" TTable and TQuery classes that expose table rows / query cursors as objects with (sub-object) fields. It exposes the DB structures as they are, but makes for easy communication with your own classes, so you can handle objects as objects and tables as tables. 3) As for your riddle at 4:15-4:24, at first I thought it might be something to do with the hard-coded "VALUES(1,", "VALUES(2,", and "where id=1", since that will only work once and is pretty weird. But, sure if the id isn't autoincrement / generated by sequence, it will work (once!), so not strictly speaking a bug, I suppose... So it has to be the double quotes around "hello", which makes that a column name reference in stead of a character-string value. (Though I think some RDBMSes might allow that. If nothing else, PROC SQL in SAS probably does.) --- [*]: Mentioning WTF I'm talking about, so people won't think I'm talking about every programming language in the world. See how easy that is, fsckwits?
@gregf3021
@gregf3021 3 ай бұрын
Bunch of butt hurt ORM users in the comments.
@tudogeo7061
@tudogeo7061 8 ай бұрын
I'm on the fence on whether to like or not. Here, have a comment maybe it helps w the algos.
@hurleyd9828
@hurleyd9828 4 ай бұрын
wtf are you talking about. most of the arguments are silly.
@MrCompSciGuy
@MrCompSciGuy 8 ай бұрын
Sorry for the bad audio y'all. Been sick for a while but couldn't put this off anymore, got so bored not doing anything. Really bad smacking, if someone has any tips on how to resolve it for future videos I'd be very grateful :D
@lardosian
@lardosian 8 ай бұрын
Wasnt that bad, maybe when your 100% the dryness will be gone. Honey and hot water should help and don't drink coffee beforehand. You should be able to remove in post with an editor if you zoom in hard on the waveform, should see little spikes which can be deleted, just make sure when deleting that the waveform meets up again on the axis.
@AK-vx4dy
@AK-vx4dy 8 ай бұрын
World should be greatfull that you share your panifull exprience and wisdom with humanity. Not all will take your advices seriously, many will argue or give you names but some they they will know.
@FainTMako
@FainTMako 7 ай бұрын
some will "know" because they are ignorant. I cant believe people can be so lazy and dishonest like you tbh.
@FainTMako
@FainTMako 7 ай бұрын
Ooof. Bad developers need to stop making youtube videos.
@oPatrickVico
@oPatrickVico 7 ай бұрын
What is wrong with the video?
@FainTMako
@FainTMako 7 ай бұрын
Lots of false statements about how ORMs function.@@oPatrickVico
@ehutch79
@ehutch79 7 ай бұрын
@@oPatrickVico A lot of the shown code is bad, and elicits a lot of 'why would you write code like that' responses. The OOP straw-man argument he makes is pretty bad specifically. Even outside of ORMs, you shouldn't be using that much inheritance in most languages, and you REALLY shouldn't be inheriting classes in your ORM like that. Once you get to the class that represents your table, if you find yourself inheriting off that, you really need to stop, backup, and reconsider your DB design. That's a dev problem, not a failing of the concept of ORMs in general.
@PurpleDaemon_
@PurpleDaemon_ 7 ай бұрын
@@oPatrickVico Almost every his example is wrong. Normal ORMs can exclude by where, count(), select specific columns, aggregate with group by...
@andrewcrook6444
@andrewcrook6444 7 ай бұрын
I agree with him but for different reasons. First I make the assumption that by SQL that we are talking out relational databases. If so, then a ORM is just a series of anti-patterns that use relational databases in ways that they were not designed for or shouldn’t be used in a particular way. Secondly I see a trend when projects grow and become more complex of developers dropping the ORM for SQL whether via an ORM SQL function or a pure database library. Also see many ORM users make mistakes because they think they don’t have to understand databases in any real detail. Lastly, people writing code in the app that should be taken care of by database itself. Some times the question isn’t if you can but whether you should.
@minor12828
@minor12828 8 ай бұрын
ORM is something bad that happened to IT. It hould be used only for prototyping and proof of concept projects.
@em_the_bee
@em_the_bee 8 ай бұрын
Any arguments, sir?
@minor12828
@minor12828 8 ай бұрын
@@em_the_bee imposible to do accurate modeling in complex scenarios because of Object-relational impedance, hard to debug issues because you tend to exclude the database team from helping in the análisis, you normally have to opt-out of the ORM for customized scenarios and some others I don't recall at the moment. If you in java world I suggest taking a look at spring-data-jdbc or myBatis. Please note spring-jdbc but spring-data-jdbc which adds a layer for handling DDD modeling features. Hope you have a good week sir.
@FainTMako
@FainTMako 7 ай бұрын
do you ever think that you could just be wrong?
@shmuel6
@shmuel6 7 ай бұрын
I actually came to the same conclusion on my own. I built my own little dynamic DNS client and from the start everyone was saying use an ORM at least on the surface. I went through what no where I'm does and I said what the F*** do I need this for I'll just write things directly in SQL as at the end of the day all my data is going to be ending up in SQL And sure enough festival did not disappoint. Very happy with my app BH. Thanks for releasing this video though and letting others know.
DONT USE AN ORM | Prime Reacts
25:46
ThePrimeTime
Рет қаралды 198 М.
everything is open source if you can reverse engineer (try it RIGHT NOW!)
13:56
Low Level Learning
Рет қаралды 1,3 МЛН
TRY NOT TO LAUGH 😂
00:56
Feinxy
Рет қаралды 19 МЛН
OMG🤪 #tiktok #shorts #potapova_blog
00:50
Potapova_blog
Рет қаралды 16 МЛН
Khóa ly biệt
01:00
Đào Nguyễn Ánh - Hữu Hưng
Рет қаралды 19 МЛН
IS THIS REAL FOOD OR NOT?🤔 PIKACHU AND SONIC CONFUSE THE CAT! 😺🍫
00:41
Rust Data Modelling Without Classes
11:25
No Boilerplate
Рет қаралды 162 М.
I’ve been using SQL wrong this whole time
9:50
CompSciGuy
Рет қаралды 23 М.
The Only External System You Need
6:24
CompSciGuy
Рет қаралды 51 М.
How GPS Changed Distributed Databases Forever
10:27
CompSciGuy
Рет қаралды 1,1 М.
Bad Way of Writing Readable Code
3:36
Adarsh Gupta
Рет қаралды 2,1 М.
I Designed A CPU (And So Can You)
19:14
Owen Gibson
Рет қаралды 6 М.
Solving one of PostgreSQL's biggest weaknesses.
17:12
Dreams of Code
Рет қаралды 175 М.
98% Cloud Cost Saved By Writing Our Own Database
21:45
ThePrimeTime
Рет қаралды 308 М.
The Untold Truth About Transactions
5:43
CompSciGuy
Рет қаралды 1,1 М.
Abstraction Can Make Your Code Worse
5:13
CodeAesthetic
Рет қаралды 617 М.
5 НЕЛЕГАЛЬНЫХ гаджетов, за которые вас посадят
0:59
Кибер Андерсон
Рет қаралды 1,6 МЛН
Секретный смартфон Apple без камеры для работы на АЭС
0:22
iPhone 12 socket cleaning #fixit
0:30
Tamar DB (mt)
Рет қаралды 47 МЛН
📦Он вам не медведь! Обзор FlyingBear S1
18:26