Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
シンプルじゃないテーブルの見つけ方
Search
sunnyone
June 25, 2024
Programming
410
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
シンプルじゃないテーブルの見つけ方
sunnyone
June 25, 2024
Transcript
14 slides
シンプルじゃないテーブルの見つけ方 @_sunnyone / 2024-06-26 at PHP 勉強会 1
今日お話すること こんな人向けにいけてないかテーブルどうかを知るためのヒントを お伝えします。 列たくさんあるんだけど、正しいのかな? 削除フラグダメって言うけど、boolean の列ってダメなの? Eloquent やDoctrine でなんとなくDB 作ってるけど、大丈夫か心
配 2
自己紹介 Yoichi Imai (@_sunnyone) / Web アプリケーションエンジニア アプリケーション層(L7) プレゼンテーション層(L6) セッション層(L5)
トランスポート層(L4) ネットワーク層(L3) データリンク層(L2) 物理層(L1) ⼤学⽣アルバイト / PHP プログラマ SIer / IT インフラエンジニア スタートアップ / アプリケーション エンジニア いまここ 3
こんなテーブル、ありませんか? ユーザー ユーザーID : bigint «PK» ⽒名 : text ⽒名カナ
: text 郵便番号 : text 住所 : text 電話番号 : text TwitterID : text Twitter トークン : text 削除フラグ : boolean 4
こんなテーブル、ありませんか? ユーザー ユーザーID : bigint «PK» ⽒名 : text ⽒名カナ
: text 郵便番号 : text 住所 : text 電話番号 : text TwitterID : text Twitter トークン : text 削除フラグ : boolean ???「シンプルじゃないんよ」 5
シンプルじゃないとは シンプルじゃないテーブル=複数の責務を持つテーブル 複数の責務を持っていると、データの整合性維持やスキーマの変 更が難しくなる ( 詳しくはアジャイル開発とデータベース設計 by soudai を参照) 6
シンプルじゃないとは ???「そうは言っても「ユーザー」は「ユーザー」では??」 7
シンプルじゃないテーブルの見つけ方 情報や構造の生存期間に着目する ↓ 1 テーブルの中で生存期間に違いがあるテーブルは「怪しい」 8
情報の生存期間(列方向)にズレがある例 ユーザー ユーザーID : bigint «PK» ⽒名 : text ⽒名カナ
: text 郵便番号 : text 住所 : text 電話番号 : text TwitterID : text Twitter トークン : text 削除フラグ : boolean ユーザー登録のタイミングでは住所なしだって? そのためにnullable ? 電話番号って追加されたりしない? 9
情報の生存期間(行方向)にズレがある例 ユーザー ユーザーID : bigint «PK» ⽒名 : text ⽒名カナ
: text 郵便番号 : text 住所 : text 電話番号 : text TwitterID : text Twitter トークン : text 削除フラグ : boolean 列としては削除フラグはいつも存在していて生存期間はずれてなさそ うだけど... ? 10
情報の生存期間(行方向)にズレがある例 削除フラグ = false 削除フラグ = true ユーザー 登録 全期間
削除 未削除の行: 全期間及び削除されていない期間に有効な情報 削除済みの行: 全期間及び削除されている期間に有効な情報 11
構造の生存期間のズレ ユーザー ユーザーID : bigint «PK» ⽒名 : text ⽒名カナ
: text 郵便番号 : text 住所 : text 電話番号 : text TwitterID : text Twitter トークン : text 削除フラグ : boolean 外部サービスってずっと使いますか?生きてますか? 12
シンプルじゃないテーブルを見つけたらどうし たら? 俺達の戦いはまだ始まったばかりだ! 13
参考資料 アジャイル開発とデータベース設計 - 変化に対応するシンプルな実 装のために必要なこと by sodai https://agilejourney.uzabase.com/entry/2022/07/28/103000 イミュータブルデータモデル by
kawasima https://scrapbox.io/kawasima/ イミュータブルデータモデル 14
More Decks by sunnyone
See All by sunnyone
AI時代のDependency Injection
sunnyone
0
49
AIコーディング時代に意識したい縦と横
sunnyone
0
150
Rustとgtk-rsで自分用GUIツールを作ろう
sunnyone
1
130
multirange 型(多重範囲型)の活用
sunnyone
0
160
開発者とのコミュニケーションのはじめかた
sunnyone
0
74
概念モデル→論理モデルで気をつけていること
sunnyone
3
590
印象に残ったLLMの使い方5選
sunnyone
0
54
Next.js App Router登場後の話
sunnyone
0
92
はやい開発のためのJSONデータ型の活用
sunnyone
0
210
Other Decks in Programming
See All in Programming
Python Lambdaにおけるテストしやすい設計とAI支援の活用 / Designing Testable Python Lambda Functions with AI
kitano_yuichi
1
350
例外からRich Errorsまで Kotlinエラーハンドリングの進化を読み解く
shiita0903
0
240
なぜ私たちは「現時点では」KMPの導入を見送ったのか
chigichan24
1
480
Engineering Biometric UX Across Android Versions | DroidKnights 2026
ryunen344
1
220
Growing PicoRuby's Ecosystem on ESP32
yuuu
2
150
baseline으로 마이그레이션, 리팩토링 안전하게 맡기기
fornewid
1
1k
AI Augmentation Techniques with Liberty
ivargrimstad
1
540
あなたの await、OS まで届いてる? strace で覗く JavaScript の非同期
hasutosasaki
1
2.4k
Crash Auto Pipelines
veronikapj
1
440
地方こそサーバーレス — 10年続けた、顔が見えるチームで確かな基盤を / Serverless Matters Most in Regional Areas — 10 Years of Building Reliable Foundations with Close-Knit Teams
seike460
PRO
2
500
SONY CISC-NEWS NWS-1750 + NWB-225 ハードウェアメンテとフレームバッファカラー対応 / KOF2026
tsutsui
0
120
はじめてのPLATEAU
nokonoko1203
1
660
Featured
See All Featured
Code Reviewing Like a Champion
maltzj
529
40k
Digital Ethics as a Driver of Design Innovation
axbom
PRO
2
550
Are puppies a ranking factor?
jonoalderson
2
4.2k
GraphQLの誤解/rethinking-graphql
sonatard
75
12k
Designing Experiences People Love
moore
143
24k
Fashionably flexible responsive web design (full day workshop)
malarkey
409
67k
StorybookのUI Testing Handbookを読んだ
zakiyama
31
7.1k
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
3.3k
How to Think Like a Performance Engineer
csswizardry
28
2.9k
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
540
How GitHub (no longer) Works
holman
316
150k
The Art of Programming - Codeland 2020
erikaheidi
57
15k