-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
データベースの記事を書き直した #364
データベースの記事を書き直した #364
Conversation
chelproc
commented
Sep 16, 2023
•
edited
Loading
edited
- 非同期処理に関する記述を大幅に削減した
- 記事全体を概念の説明と演習に分けた
- ツール類の説明を演習パート冒頭に移動した
Deploying with
|
Latest commit: |
57cfded
|
Status: | ✅ Deploy successful! |
Preview URL: | https://41e1ac78.utcode-learn.pages.dev |
Branch Preview URL: | https://rewrite-database.utcode-learn.pages.dev |
|
||
データベースサーバーは、データを保存したり、参照するための専用のサーバーです。Web の世界では、ブラウザが直接データベースサーバーと通信することはほとんどなく、基本的には Node.js などのウェブサーバーがデータベースサーバーと通信します。リレーショナルデータベースは、データベースの中でも最も多く使われる種類のもので、Excel のような表形式でデータを保持するという特徴があります。 | ||
それでは、送られてきたデータをファイルに記録すれば大丈夫でしょうか。確かに、サーバーが終了してもデータは残りそうです。ところが、もし皆さんが作ったサービスが大きく成長し、一つのサーバーではリクエストを捌ききれなくなったとしましょう。すると、ファイルに保存したデータは複数のサーバーで共有できないことが問題になります。また、記録されているデータが膨大になってくると、ファイルの内容を読み書きするだけでも大変そうです。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ここらへんイメージが湧きにくいので、図がほしいです。
|
||
データベースサーバーは、データを保存したり、参照するための専用のサーバーです。Web の世界では、ブラウザが直接データベースサーバーと通信することはほとんどなく、基本的には Node.js などのウェブサーバーがデータベースサーバーと通信します。リレーショナルデータベースは、データベースの中でも最も多く使われる種類のもので、Excel のような表形式でデータを保持するという特徴があります。 | ||
それでは、送られてきたデータをファイルに記録すれば大丈夫でしょうか。確かに、サーバーが終了してもデータは残りそうです。ところが、もし皆さんが作ったサービスが大きく成長し、一つのサーバーではリクエストを捌ききれなくなったとしましょう。すると、ファイルに保存したデータは複数のサーバーで共有できないことが問題になります。また、記録されているデータが膨大になってくると、ファイルの内容を読み書きするだけでも大変そうです。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
「また、記録されている」以降が分かりにくいです。
@@ -12,36 +12,70 @@ import copySecretValuesVideo from "./copy-secret-values.mp4"; | |||
import prismaDbPushVideo from "./prisma-db-push.mp4"; | |||
import createRecordInDatabaseVideo from "./create-record-in-database.mp4"; | |||
|
|||
## リレーショナルデータベース |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
右のサイドバーがおかしいので、セクションを作った方が良さそうです。
|
||
次の図は、リレーショナルデータベースの基本的な概念である、**テーブル**、**カラム**、**レコード**について整理した図です。リレーショナルデータベースを用いる一般的なアプリケーションでは、アプリケーション開発時にテーブルとカラムを作成しておき、ユーザーの操作に応じてレコードを追加・編集・削除していきます。 | ||
**データベース**は、このようなデータに関する諸問題を解決するためのシステムです。データベースは、通常サーバーとして動作します。つまり、**データベースサーバー**は、保持しているデータに対する参照や更新のためのリクエスト (**クエリ**) を受け、その結果をレスポンスとしてクライアントに返します。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ユーザーという意味でのクライアントと勘違いしかねない。
## ElephantSQL で PostgreSQL を使用する | ||
リレーショナルデータベースに対するクエリは、通常 **SQL** と呼ばれる言語を用いて記述します。データベースクライアントとして用いるライブラリによっては、SQL を直接用いることなく、そのライブラリが提供する専用の関数等を用いてデータベースに対してクエリを発行できることがあります。 | ||
|
||
## 演習 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
演習という概念は初出であるので、どういう構成かわかりにくいかもしれないです。課題との違いがわかりにくそう。
演習と言いつつ、内容もけっこう大事な内容なので、演習という扱いでなく地の文でも良いような気がしています。
逆に、これより上の内容のタイトルを工夫すれば済むような気がします。
- [**`Prisma` 拡張機能**](https://marketplace.visualstudio.com/items?itemName=Prisma.prisma): VS Code の拡張機能。`.prisma` ファイルに対する補完やフォーマットの機能を提供する。 | ||
- [**`.prisma` ファイル**](https://www.prisma.io/docs/concepts/components/prisma-schema): データベースのテーブル構造を記述するファイル。`prisma` パッケージのコマンドを用いて実際のデータベースサーバーに反映させる。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ここ2つの説明が前後しています。先に、.prisma
ファイルを説明した方が良さそう。
|
||
:::tip (発展) Promise | ||
上記の 3 つのメソッドは、<Term type="asynchronousProcess">**非同期処理**</Term>を行います。JavaScript における非同期処理とは、ファイルの入出力やネットワーク通信など、JavaScript の外側の時間のかかる処理の完了を待つ間、ほかの処理を実行できるようにする仕組みです。非同期処理を行う関数を使用するためには、次の 2 つを行います。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
「JavaScriptの外側」という表現が伝わりにくい気がします。しばらくどういう意味かわからなかったです。
|
||
次の図は、リレーショナルデータベースの基本的な概念である、**テーブル**、**カラム**、**レコード**について整理した図です。リレーショナルデータベースを用いる一般的なアプリケーションでは、アプリケーション開発時にテーブルとカラムを作成しておき、ユーザーの操作に応じてレコードを追加・編集・削除していきます。 | ||
**データベース**は、このようなデータに関する諸問題を解決するためのシステムです。データベースは、通常サーバーとして動作します。つまり、**データベースサーバー**は、保持しているデータに対する参照や更新のためのリクエスト (**クエリ**) を受け、その結果をレスポンスとしてクライアントに返します。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ここら辺は概念が複雑なので「リクエスト」「レスポンス」「クライアント」にホバーすると用語解説が出るようにしたほうがいい気がします。あと、Expressの章へのバックリンクも置いておいたほうがいい気がします
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
たしかに。
|
||
[PostgreSQL](https://www.postgresql.org) は、代表的なリレーショナルデータベースです。[ElephantSQL](https://www.elephantsql.com) を利用すると、無料のアカウント登録のみで、PostgreSQL サーバーが利用できます。 | ||
多くのデータベースをグラフィカルに操作できるソフトウェアです。PostgreSQL にも対応しています。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
「グラフィカルに」よりも「マウスで視覚的に」とかのほうがわかりやすい気がします
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
この表現は迷ったのですが「グラフィカルに」「視覚的に」はほぼ同義ですし、「マウスで...」はあまり正確ではないので避けた方がいいと思います。
本当は「GUIで」としたかったのですが教材上では他に使っている部分がないので用語を知らなくてもある程度雰囲気を理解できる「グラフィカルに」という言葉の選択をしています
- Data center: `AP-NorthEast-1 (Tokyo)` | ||
主にリレーショナルデータベースを操作するための Node.js の<Term type="library">ライブラリ</Term>です。複数の構成要素からなります。 | ||
|
||
- [**`@prisma/client` パッケージ**](https://www.npmjs.com/package/@prisma/client): 実行時に用いる npm のパッケージ。JavaScript プログラムから使用する。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
なんの「実行時」かはっきりしておいたほうがいい気がします
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ですね。