Now Reading
I Do not Want Your Question Language

I Do not Want Your Question Language

2023-06-17 05:52:06

This publish could seem a bit harsh, however I’m bored with the “SQL shaming” that has someway change into a factor within the business. I’ve a proper to disagree, don’t I?

Yearly or so, a brand new general-purpose database engine comes out. And that’s nice! It will possibly carry new worthwhile approaches, architectures, and instruments (plus, constructing database engines is enjoyable).

Usually this new database engine comes with a brand new question language. And that’s most likely good, too. Or perhaps it’s not.

Easy and stylish

An elegant query language for a more civilized age
Oh, it is elegant and civilized? Certain, I will chunk.

What puzzles me is that each time the authors declare that having this brand-new question language is someway a power. It’s not. It’s a weak spot. Studying an entire new language simply to question your database is a burden. I don’t need to do this.

We have already got a typical floor language for general-purpose databases. It’s referred to as SQL. I’d somewhat use it together with your database.

???? I’m not speaking about software program that targets a selected slender area area. Having a separate area language for particular use instances makes excellent sense.

Certain, your language is elegant. That doesn’t assist me. First, it’s nonetheless simpler to write down a barely longer question in SQL than to be taught a brand new question language. Second, your supposedly easy language will change into advanced anyhow — as quickly as I attempt to clear up real-world duties with it. So why hassle?

Higher than SQL

A comparison that speaks for itself
Simply take a look at that ugly SQL beast.

Typically the authors of a brand new question language attempt to body SQL as terribly advanced. Let’s take an instance from one in all these “post-SQL” databases. A comparability that, based on the authors, speaks for itself.

???? I’m utilizing a selected “post-SQL” database (with out naming it) for instance my level right here, as a result of its touchdown web page is a vivid instance of “SQL shaming”. This isn’t a criticism of the database or its authors. I’m certain it’s a fantastic product.

FancyQL:

choose Film {
  title,
  actors: {
   title
  },
};

SQL (because the authors of FancyQL see it):

SELECT
  title,
  Actors.title AS actor_name
FROM Film
 LEFT JOIN Movie_Actors ON
  Film.id = Movie_Actors.movie_id
 LEFT JOIN Individual AS Actors ON
  Movie_Actors.person_id = Individual.id

SQL (as it could be):

choose
  title,
  actors.title
from films
  be part of movies_actors utilizing(movie_id)
  be part of actors utilizing(actor_id)

Hmm. One other instance?

FancyQL:

choose Film {
  title,
  actors: {
   title
  },
  ranking := math::imply(.opinions.rating)
} filter "Zendaya" in .actors.title;

SQL (because the authors of FancyQL see it):

SELECT
  title,
  Actors.title AS actor_name,
  (SELECT avg(rating)
    FROM Movie_Reviews
    WHERE movie_id = Film.id) AS ranking
FROM
  Film
  LEFT JOIN Movie_Actors ON
    Film.id = Movie_Actors.movie_id
  LEFT JOIN Individual AS Actors ON
    Movie_Actors.person_id = Individual.id
WHERE
  'Zendaya' IN (
    SELECT Individual.title
    FROM
      Movie_Actors
      INNER JOIN Individual
        ON Movie_Actors.person_id = Individual.id
    WHERE
      Movie_Actors.movie_id = Film.id)

SQL (as it could be):

choose
  title,
  actors.title,
  (choose avg(rating) from opinions
   the place movie_id = films.movie_id) as ranking
from films
  be part of movies_actors utilizing(movie_id)
  be part of actors utilizing(actor_id)
the place movie_id in (
  choose movie_id
  from actors be part of movies_actors utilizing(actor_id)
  the place actors.title = 'Zendaya'
)

movies.sql

See Also

A bit verbose. However perhaps SQL will not be that advanced in spite of everything? In any other case, why would you paint it scarier than it truly is?

Fashionable

Designed for devs, not suits
Let’s throw in some suite-shaming!

Right here is one other widespread argument:

SQL was designed with Seventies businessmen in thoughts, and it reveals.

True, SQL was designed within the Seventies. However how is {that a} weak spot? Everybody is aware of SQL. All main database engines assist SQL. SQL is expressive sufficient to unravel any data-related process. SQL has a strong requirements committee that maintains and improves it. What can your language provide apart from being created within the 2020s?

I can go on, however I don’t assume it’s crucial. My level is easy.

I don’t want your fancy question language. I’d follow SQL.

Perhaps it’s simply me.

Observe @ohmypy on Twitter to maintain up with new posts ????



Source Link

What's Your Reaction?
Excited
0
Happy
0
In Love
0
Not Sure
0
Silly
0
View Comments (0)

Leave a Reply

Your email address will not be published.

2022 Blinking Robots.
WordPress by Doejo

Scroll To Top