0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

DB設計でつまづいたことをまとめてみた

Last updated at Posted at 2020-04-12

カリキュラムで使った文字列の型をまとめます。
案外用途を忘れているもので…(自分だけ?)

DB設計でつまづいたこと

 1.カラムで使う文字列の型
 2.リレーション

1.カラムで使う文字列の型 一覧

  - string
 - text
  - integer
  - references

  ★string

  文字列(250字以内)

    <使用カラム例>
     - name
     - address
     - tel
     - office
        など

  ★text

  文字列 (250字以上)

   <使用カラム例>
     - post
     - comment
        など

  ★integer

  整数型

   <使用カラム例>
     - id
     - user_id
     - post_id
         など

  ★references

  外部キーの定義

     他テーブルへの外部キーの定義
     _idがついた整数
     ※referencesは_idを省略する事ができる

2.リレーション

ER図において、リレーションを示すあの変な矢印
<その1>
→ has_many を表す ※1対多
スクリーンショット 2020-04-12 22.54.08.png
← belongs_to を表す ※多対1

<その2>
スクリーンショット 2020-04-12 22.54.30.png
 ⇆ has_one を表す ※1対1

この辺がよく理解できてからはある程度スムーズに進められた。

以上

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?