Is there a programming language specifically designed for interacting with SQL databases that avoids the need for Object-Relational Mappers (ORMs) to solve impedance mismatch from the start?

If such a language exists, would it be a viable alternative to PHP or Go for a web backend project?

  • @Corbin
    link
    English
    13 months ago

    The classic example is the N+1 query pattern, where the number of generated queries is linear in the number of rows returned by the first query.

    • @[email protected]
      link
      fedilink
      63 months ago

      This is not a problem for a modern ORM, JOINs are supported by most ORMs I’ve worked with for many years.

      Var cars = await db.Cars
          .Include(c => c.Wheels)
          ToListAsync();
      
      foreach (var car in cars)
      {
          Console.WriteLine(car.Model);
          foreach (var wheel in car.Wheels)
          {
              Console.WriteLine(wheel.Id);
          }
      }
      

      This will get all the cars and their associated wheels in 1 single query by performing a JOIN operation using Entity Framework Core, assuming there’s a FK for Wheel to Car.