1
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

オブジェクトリレーショナルマッピング(ORM)とは

Posted at

プログラミングとデータベースのやりとりを、し易くするものです。

DBでは、下記のように書いて、データベースにアクセスするSQLという言語があります。
select id, name, age from user;

DBに直接アクセスするときは、これでいいのですが、JavaScript、Java、Pythonなどのプログラミング言語からアクセスするときはどうするでしょう。

方法1 SQLの文字列を直接使う

const a = 'select id, name, age from user;' 
const db = postgreSql()

const results = db.execute(a)
print(results)

方法2 ORMを使う

const userORM = User() 

const results = userORM.get()
print(results)

これをみて、何をしていそうか想像してみましょう。
2つ目はUser()が、おそらくUserテーブルに対応していて、getとやるとデータが取れそうです。

ORMは、テーブルに似せたコードを作り、それを通じて、データベースとのやりとりをする方法です。

JavaScriptの有名どころでは、Prismaがあります。

1
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?