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
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
sunnyone
June 25, 2024
Programming
400
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
シンプルじゃないテーブルの見つけ方
sunnyone
June 25, 2024
More Decks by sunnyone
See All by sunnyone
AI時代のDependency Injection
sunnyone
0
38
AIコーディング時代に意識したい縦と横
sunnyone
0
130
Rustとgtk-rsで自分用GUIツールを作ろう
sunnyone
1
120
multirange 型(多重範囲型)の活用
sunnyone
0
150
開発者とのコミュニケーションのはじめかた
sunnyone
0
71
概念モデル→論理モデルで気をつけていること
sunnyone
3
580
印象に残ったLLMの使い方5選
sunnyone
0
51
Next.js App Router登場後の話
sunnyone
0
90
はやい開発のためのJSONデータ型の活用
sunnyone
0
200
Other Decks in Programming
See All in Programming
AI時代のFlutter品質設計 — アプリ品質を守るQuality Layers
omatty198
0
220
エージェントを使い続けるためのメタワーク / Meta-work for keeping using the agent
rkaga
6
1.9k
Compiling a real-world CLI tool to native with Static Hermes
tmikov2023
0
130
contenteditable と日本語入力に向き合う
colorful12
0
230
クラウドゲーミングのパフォーマンス最適化に挑む / Cloud Gaming Performance Tuning
vivion
0
300
私なりのハーネスエンジニアリング ~独自の言語処理系の開発を通して~
seosoft
0
110
Python Lambdaにおけるテストしやすい設計とAI支援の活用 / Designing Testable Python Lambda Functions with AI
kitano_yuichi
1
230
Performance Optimization With LLMs
xleitix
0
220
パスワード再設定メールのURLについて知っておこう
uyuki234
0
190
GraphQL の onError と Nullability のこれから
quramy
0
190
オーケストレーション記述言語 Katari
yukikurage
0
200
Seven New Principles of Software Engineering
yegor256
0
360
Featured
See All Featured
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
1.1k
Become a Pro
speakerdeck
PRO
31
6.3k
Prompt Engineering for Job Search
mfonobong
0
550
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
2
540
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
330
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
650
Un-Boring Meetings
codingconduct
0
470
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
68
59k
Test your architecture with Archunit
thirion
2
2.5k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
Between Models and Reality
mayunak
4
520
Statistics for Hackers
jakevdp
799
230k
Transcript
シンプルじゃないテーブルの見つけ方 @_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