Back

March 16, 2024

60 views

Turbocharge Your Database: The Art of SQL Indexing and Database Performance Enhancement

X

Toufiq Hasan Kiron

@hashtagkiron

HeaTurbocharge_Your_Database_The_Art_of_SQL_Indexing_and_Database_Performance_Enhancement_ding_oar0fp

Let's explore what Prisma is, why it exists, and what problem it aims to solve. Learning Prisma is essential for a JavaScript or TypeScript developer.

What is Prisma?

Prisma is an ORM (object-relational mapping) that can be called a JavaScript library or a database toolkit. It can be used for database management very quickly. This ORM is called the next-generation ORM. Why is Prism called this? It is very advanced and developer-friendly, and it allows easy querying of databases using type-safe code. The most exciting thing is that with Prisma, you write queries or create schemas and models. With those codes, you work with any database platform, such as SQL Lite, MY SQL, PostgreSQL, or MongoDB. Moreover, Prisma can be used in any combination within the JavaScript ecosystem. According to Prisma, since the launch of Prisma ORM, more than 150,000 developers have adopted Prisma for new or existing projects. Developers have also adopted Prisma with love because It is easy to use and provides automatic type generation, declarative database migrations, and direct integration in the VS Code IDE. Once you fall in love with Prisma, Brother Russell, you will tell yourself where this butter thing has been all this time. Do you understand why it is essential to learn Prisma?

Why Prisma?

Debugging is a significant problem in application development when working with relational databases. Debugging SQL queries or complex ORM objects often takes hours of development time. This is where Prisma comes in, providing a clean and type-safe API for developers to query the database and return plain JavaScript objects. Prisma's primary goal is to make application developers more productive when working with databases. Here are a few examples of how Prisma achieves this:

  • Thinking about objects instead of mapping relational data.
  • Queries, not classes, to avoid complex model objects.
  • Single source of truth for database and application models.
  • Healthy constraints that prevent common pitfalls and anti-patterns.
  • An abstraction that makes the right thing easy ("pit of success").
  • Type-safe database queries that can be validated at compile time.
  • Less boilerplate so developers can focus on the essential parts of their app.
  • Auto-completion in code editors instead of needing to look up documentation

Should you use Prisma?

This could be Prisma's primary use case if you build a server-side application. Server-side applications typically operate on data through technologies such as REST, GraphQL, or gRPC; they are usually built as microservices or monolithic apps, all of which Prisma is a beneficial solution if you care about productivity and developer experience. Whether new to SQL or senior, Prisma will give you maximum productivity.

When should you not use Prisma?

Prisma is probably not good for you if you want complete control over all database queries. Or you want to use row SQL for your database queries. You can find more details on the Prisma documentation.

Prisma is an ORM that provides a fully type-safe API and simplified database access. You can use Prisma > tools to build GraphQL or REST APIs or as part of a full-stack application. How much you utilize Prisma is > up to you.

Let's pack up and move on to a more exciting and engaging topic another day.

Additional reading and resources:

https://www.prisma.io/docs/concepts

https://www.prisma.io/dataguide/database-tools/top-nodejs-orms-query-builders-and-database-libraries

There are some open-source application examples built using Prisma.

https://github.com/kentcdodds/kentcdodds.com

https://github.com/poulainv/tottem

https://github.com/calcom/cal.com