KAEDE Hack blog

JavaScript 中心に ライブラリなどの使い方を解説する技術ブログ。

MySQL の Parent Child RDB とは何か

why

  • 仕事で、Blitz SQL の Questions と Children の 関係を 「階層構造」と表現して日報に書いたら、メンターから「言い方違いますよ」とのレビューが入った
  • ググって記事を読んで見たら Why Should We Use Parent-Child Relationships とか言う根本的なセクションがあったから、まとめておく

説明

scotch.io

Parent-child relationship in MySQL has to deal with establishing some hierarchal dependencies between records in a database table.

  • MySQL の親子構造は、DB テーブルのレコードの間の階層間の依存性を処理するためにある

In MySQL terms, it means say that “row 12 is the parent of row 14” and stuff like that.

  • MySQL の言葉では、「12行目は14行目の親である」と言うようなものだ

In business terms, it will mean establishing a dependency relationship between two similar entities.

  • ビジネスの言葉では、似た2つの実態のなかで依存関係を設立する、と言うことを意味する

For example, keeping a record of all the people in a village and matching parents to their children.

  • 例えば、村の人たちのレコードを全てとっておいて、親と子供を会わせるようなものだ

村の DB の中に親テーブルがあって、その子供テーブルとして子供テーブルがあるわけではなく

村の DB の中に 村テーブルと人々のレコードがあって、その人々が同じ階層の中で行として作られていて、その行どうしで依存関係があるってこと????

f:id:kei_s_lifehack:20201029151826p:plain

  • 右の並列してるのではやばいから左を使おうって文脈かな?

動かしてみる

https://scotch.io/tutorials/how-to-implement-parent-child-relationship-in-mysql#toc-why-should-we-use-parent-child-relationships

  • MySQL これで動かす
  • せっかく前 Docker 環境作ったし, これで Docker で動かすか

github.com

  • 作ってないやんけ!!!!!!!!!!!!!!
  • postgres のも ちゃんと書いてないやん

書いた