Skip to content

Commit

Permalink
PostgreSQL: Add: Not Null (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
ma91n authored Feb 5, 2025
1 parent 64be9c5 commit 9c1ecb2
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions documents/forDB/postgresql_guidelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -894,9 +894,19 @@ CREATE TABLE sales_detail (

## NOT NULL制約

利用について制限はない。データモデルに即して適切に設定すること。
データモデルに合わせて適切に設定する。「データ型」章に関連する記載があるので、参照すること。

基本姿勢としてはできる限りNOT NULL化できないか考えることを推奨する。

例えば、[NULL撲滅委員会](https://mickindex.sakura.ne.jp/database/db_getout_null.html) の記事には、「未コード化用コード」の例がある。

> ISO の性別コードでは、1:男性、2:女性の他に、0:未知、9:適用不能という二つの未コード化用コードが体系に組み込まれています。
>
> コード9は法人に使われます。
>
> これは素晴らしい解決です。図らずもコッドが分類した二つの NULL、未知と適用不能に対応するコードが採用されています。
詳細は、「データ型」章を参照すること
上記のように、「不明」を示す区分値を用意できないか検討する

## 検査制約(CHECK制約)

Expand Down

0 comments on commit 9c1ecb2

Please sign in to comment.