Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
はじめてのB2B SaaSデータモデリング in 吉祥寺.pm#18
Search
sasaki nobuya
May 17, 2019
Programming
6
10k
はじめてのB2B SaaSデータモデリング in 吉祥寺.pm#18
sasaki nobuya
May 17, 2019
Tweet
Share
More Decks by sasaki nobuya
See All by sasaki nobuya
エンジニアがプロダクトに向き合える組織づくり / Improve Product Development
mnc
6
4.2k
エンジニアがプロダクトに向き合うための意思決定カイゼン
mnc
4
2.2k
はじめてのB2B SaaSデータモデリング in Builderscon 2019
mnc
9
4.2k
AWSインフラ設計とDB設計からわかるB2B SaaSのおもしろさ
mnc
2
1.3k
B2B SaaS開発 Configurabilityとマルチテナントをがんばる α版編
mnc
2
630
本番データを安全に利用する
mnc
0
2.7k
Other Decks in Programming
See All in Programming
色々なIaCツールを実際に触って比較してみる
iriikeita
0
330
Arm移行タイムアタック
qnighy
0
330
型付き API リクエストを実現するいくつかの手法とその選択 / Typed API Request
euxn23
8
2.2k
카카오페이는 어떻게 수천만 결제를 처리할까? 우아한 결제 분산락 노하우
kakao
PRO
0
110
距離関数を極める! / SESSIONS 2024
gam0022
0
280
macOS でできる リアルタイム動画像処理
biacco42
9
2.4k
アジャイルを支えるテストアーキテクチャ設計/Test Architecting for Agile
goyoki
9
3.3k
ペアーズにおけるAmazon Bedrockを⽤いた障害対応⽀援 ⽣成AIツールの導⼊事例 @ 20241115配信AWSウェビナー登壇
fukubaka0825
6
2k
Make Impossible States Impossibleを 意識してReactのPropsを設計しよう
ikumatadokoro
0
180
CSC509 Lecture 11
javiergs
PRO
0
180
AI時代におけるSRE、 あるいはエンジニアの生存戦略
pyama86
6
1.2k
CSC509 Lecture 09
javiergs
PRO
0
140
Featured
See All Featured
The Cult of Friendly URLs
andyhume
78
6k
The Art of Programming - Codeland 2020
erikaheidi
52
13k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
109
49k
Building Better People: How to give real-time feedback that sticks.
wjessup
364
19k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
16
2.1k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
159
15k
Become a Pro
speakerdeck
PRO
25
5k
A Philosophy of Restraint
colly
203
16k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
VelocityConf: Rendering Performance Case Studies
addyosmani
325
24k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
169
50k
Transcript
͡Ίͯͷ B2B SaaS σʔλϞσϦϯά A1Aגࣜձࣾ ࠤʑ Ԇ @__mnc90
Name ࠤʑ Ԇ Company A1Aגࣜձࣾ (ΤʔϫϯΤʔ) Career ৯ϩά → Speee
→ A1AΛڞಉۀ URL twitter.com/__mnc90 manchose.hatenablog.jp About ٕज़ͷऀͱͯ͠RFQΫϥυͷσʔλ ϕʔεઃܭͱΠϯϑϥߏஙɺ৫ͮ͘Γͳ ͲΛ୲
B2BͷऔҾΛϫϯϥϯΫ্ʹ Vision
B2BͷऔҾΛϫϯϥϯΫ্ʹ Vision A1A
ͬͨ΄͏͕Α͍͜ͱͳΜͯ ΄ͱΜͲͰ͖ͳ͍ͱ֮ޛ͢Δ ͬͨ΄͏͕Α͍͜ͱͷ5% ͘Β͍͔͠Ͱ͖ͳ͍ͱߟ͑Δ ελʔτΞοϓͷγεςϜ։ൃ
ͦΕͰఘΊͨΒμϝͳ෦ʹͷΈूத͢Δ ελʔτΞοϓͷγεςϜ։ൃ
Horizontal SaaSΑΓɺ͞Βʹਂ͍υϝΠϯ͕ࣝඞཁ Vertical SaaS
Vertical SaaS ۀքಛԽܕͷSaaSɻoctͳͲʢݐઃϓϩδΣΫτཧSaaSʣ Horizontal SaaS ৬छɾػೳʹಛԽͨ͠SaaSɻSalesforceSmartHRͳͲ Vertical SaaSͱHorizontal SaaS
“DBͷण໋ΞϓϦέʔγϣϯΑΓ͍” @soudai1025 ͞Μ DBͷॏཁੑ
ͬͨ΄͏͕ྑͦ͞͏ͳ͜ͱ TDD IaC GraphQL React TypeScript Serverless Kubernetes GitOps Apex
Atomic Design DDD σʔλ ϞσϦϯά
TDD IaC GraphQL React TypeScript Serverless Kubernetes GitOps Apex Atomic
Design DDD σʔλ ϞσϦϯά ͬͨ΄͏͕ྑͦ͞͏ͳ͜ͱ
͡ΊͯͷB2B SaaSͷσʔλϞσϦϯά
ۀߪങ෦͚ݟੵࠪఆͷSaaS RFQΫϥυ Product
None
1 Multi Tenancyͳςʔϒϧઃܭ 2 جຊNullΛڐՄ͠ͳ͍ 3 Πϕϯτͷநग़ൣғΛυϝΠϯͷத৺ʹߜΔ 4 ֎෦Ωʔͷ࣋ͪํ͔ΒσʔλͷϥΠϑαΠΫϧΛߟ͑Δ
1. Multi Tenancyͳςʔϒϧઃܭ
“ಉ͡γεςϜαʔϏεΛෳͷޓ͍ʹແؔͳར༻ ऀ͕ؒڞಉͰར༻͢ΔํࣜͰɺͦΕͧΕͷར༻ऀΞ Χϯτ໊ͳͲͷࢿ֨ใΛݩʹ۠ผ͞ΕɺͦΕͧΕ γεςϜ্ʹઐ༻ͷྖҬઃఆͳͲ͕༩͑ΒΕΔɻ” Multi Tenancy ग़ల e-words.jp/w/Ϛϧνςφϯτ.html
Ϣʔβʔاۀ͔Β͢Δͱ͕ࣗγεςϜΛಠར༻͍ͯ͠ΔΑ͏ʹݟ͑Δ ࣮ମSingle Source ෳͷςφϯτ͕1ͭͷγεςϜʹ૬Γ
Multi Tenancyͷํ๏ 1 ςφϯτຖʹDatabase or SchemaΛ 2 શςʔϒϧʹtenant_idΧϥϜΛ༻ҙ
Multi Tenancyͷํ๏ 1 ςφϯτຖʹDatabase or SchemaΛ 2 શςʔϒϧʹtenant_idΧϥϜΛ༻ҙ migration࣌ؒͷര૿ͳͲεέʔϥϏϦςΟʹ͋Γ
اۀؒऔҾܕSaaSͷMulti Tenancy ςφϯτΛͲͷ୯ҐͰ࡞͢Δ͔
αϓϥΠϠʔόΠϠʔͷςφϯτʹॴଐ͢Δ όΠϠʔA όΠϠʔB όΠϠʔC αϓϥΠϠD αϓϥΠϠE αϓϥΠϠD αϓϥΠϠG αϓϥΠϠF αϓϥΠϠF
αϓϥΠϠH tenant_id: 1 tenant_id: 2 tenant_id: 3
αϓϥΠϠʔόΠϠʔผςφϯτʹ͢Δ όΠϠʔA όΠϠʔB όΠϠʔC αϓϥΠϠF tenant_id: 1 tenant_id: 2 tenant_id:
3 tenant_id: 4 tenant_id: 5 tenant_id: 6 αϓϥΠϠD αϓϥΠϠE
σʔλͷॴ༗ऀ͔Βςφϯτͷ୯ҐΛߟ͑Δ
Α͋͘Δཁ ୀձޙͷσʔλͷཧআ
αϓϥΠϠʔ͕ड৴ͨ͠ݟੵใόΠϠʔͷୀձޙʹআ͞ΕΔ͖ʁ ϝʔϧΛϝλϑΝʔͱͯ͠ߟ͑Δ
ୀձޙαϓϥΠϠʔ͕ड৴ͨ͠σʔλΔ͖
ςφϯτͷ୯Ґ 1 αϓϥΠϠʔόΠϠʔͷςφϯτʹॴଐ͢Δ 2 αϓϥΠϠʔόΠϠʔผςφϯτʹ͢Δ
ςφϯτͷ୯Ґ 1 αϓϥΠϠʔόΠϠʔͷςφϯτʹॴଐ͢Δ 2 αϓϥΠϠʔόΠϠʔผςφϯτʹ͢Δ
1 όΠϠʔͷୀձޙͷσʔλআ͕όΠϠʔςφϯτ୯ҐͰ আ͢Δ͚ͩͰରԠ͕ྃ͢Δ 2 اۀຖʹݸผͷΞΧϯτཧϙϦγʔΛద༻Ͱ͖Δ ※اۀຖʹϙϦγʔ͕ҟͳΔ͜ͱ͕ଟ͍ 3 αϓϥΠϠʔςφϯτ͕ॏෳ͠ͳ͍ͨΊαϓϥΠϠʔʹͱ ͬͯσʔλͷҰݩཧ͕Ͱ͖Δͱ͍͏ϝϦοτΛఏڙͰ ͖Δ
ϝϦοτ
Example ݟੵґཔ(request_for_quotations)ʹରͯ͠ ݟੵճ(quotations)Λߦ͏߹
request_for_quotations ID produce_number 1 300 2 60 3 1200 ID
unit_price request_for_quotation_id 1 100 1 2 90 2 quotations ૉͳઃܭ
request_for_quotations ID produce_number 1 300 2 60 3 1200 ID
unit_price received_request_for_quotation_id 1 100 1 2 90 2 quotations σʔλͷॴ༗ऀΛߟ͑ͨઃܭ ID produce_number 1 300 2 60 3 1200 received_request_for_quotations ID unit_price request_for_quotation_id 1 100 1 2 90 2 received_quotations
2. جຊNULLΛڐՄ͠ͳ͍
NullableͳΧϥϜ͕͋Δ߹ ϥΠϑαΠΫϧͷҟͳΔσʔλ͕ ಉ͡ςʔϒϧʹೖ͍ͬͯΔ͜ͱ͕ଟ͍ NULLΛڐՄ͠ͳ͍ཧ༝
Example
materials ID name code 1 ϒϥέοτ 391001 2 εϥΠυϘοΫε ϒϥέοτ
NULL 3 ݻఆۚ۩ 369221
materials ID name 1 ϒϥέοτ 2 εϥΠυϘοΫε ϒϥέοτ 3 ݻఆۚ۩
ID material_id code 1 1 391001 2 3 369221 material_codes ͱΓ͋͑ͣNULLແ͘ͳͬͨʂ Ͱɺ͜ΕͰ͍͍ͷ͔ʁ
ͳͥNULLؚ͕·ΕΔͷͩΖ͏
1 material_codeΛͦͦཧ͍ͯ͠ͳ͍اۀ͕͋Δ 2 ࢼ࡞ͷஈ֊Ͱmaterial_codeΛൃ൪ͤͣʹݟੵґཔ Λߦ͍ɺίετͷ֓ࢉΛ֬ೝ͔ͯ͠ΒcodeΛൃ൪͢Δͱ ͍͏ۀϑϩʔ͕͋Δ
1 material_codeΛͦͦཧ͍ͯ͠ͳ͍اۀ͕͋Δ 2 ࢼ࡞ͷஈ֊Ͱmaterial_codeΛൃ൪ͤͣʹݟੵґཔ Λߦ͍ɺίετͷ֓ࢉΛ֬ೝ͔ͯ͠ΒcodeΛൃ൪͢Δͱ ͍͏ۀϑϩʔ͕͋Δ ࢼ࡞ͷݟੵґཔۀͱ͍͏Ϣʔεέʔε͕ͬͦ͝Γൈ͚͍ͯΔ
materials ID name 1 ϒϥέοτ 2 εϥΠυϘοΫε ϒϥέοτ 3 ݻఆۚ۩
ID material_id code 1 1 391001 2 3 369221 production_materials prototype_materials ID material_id 1 2
ϦιʔεͱΠϕϯτΛ۠ผ͢Δɻ ΠϕϯτۀͷهͰ͋Γɺ B2B SaaSͷத৺తଘࡏɻ 3. Πϕϯτͷநग़ൣғΛυϝΠϯͷத৺ʹߜΔ
͔͠͠ɺ͋ΒΏΔϦιʔεʹର͢Δߋ৽ΛΠϕ ϯτͱͯ͠ϞσϦϯάͯ͠͠·͏ͱ࣮ίετ ͕ߴ͘ͳͬͯ͠·͏ɻ ͦͷͨΊɺղܾ͍ͨ͠υϝΠϯͷத৺ʹҐஔ͢ ΔۀͷΈΠϕϯτͱͯ͠ϞσϦϯά͢Δɻ 3. Πϕϯτͷநग़ൣғΛυϝΠϯͷத৺ʹߜΔ ※ @kawasima͞ΜͷൃදͰֶͼ·ͨ͠
Example (materials)ͷߋ৽ʹ͍ͭͯߟ͑Δ
materials ID name updated_at 1 ϒϥέοτA 2019-05-16 09:10:11 2 ۩
2019-05-17 12:51:02 materialsςʔϒϧΛ ߋ৽͢Δ߹
ID name created_at material_id 1 ϒϥέοτA 2019-05-16 09:10:11 1 2
ϒϥέοτB 2019-05-26 11:42:11 1 materials ID name 1 ϒϥέοτ 2 ۩ material_updates ߋ৽Πϕϯτͷςʔϒϧ material_updatesΛ༻ҙ
ID name created_at material_id 1 ϒϥέοτA 2019-05-16 09:10:11 1 2
ϒϥέοτB 2019-05-26 11:42:11 1 materials ID name 1 ϒϥέοτ 2 ۩ material_updates Ռͨͯ͠ɺmaterialsͷߋ৽ۀ RFQΫϥυͷղܾ͢ΔυϝΠ ϯͷத৺ͳͷ͔ʁ
ID name created_at material_id 1 ϒϥέοτA 2019-05-16 09:10:11 1 2
ϒϥέοτB 2019-05-26 11:42:11 1 materials ID name 1 ϒϥέοτ 2 ۩ material_updates ҧ͏ͣɻ ͋͘·Ͱmaterialsͷߋ৽ཤྺͷཧجװγε ςϜ(ERP)Ͱߦ͍ͬͯΔɻ ͳΒɺmaterialsΛߋ৽ͯ͠͠·ͬͯྑ͍ɻ ͠CS༻ʹཤྺ͕΄͔ͬͨ͠߹ผͷσʔλ ετΞʹೖΕΔͳΓ͢ΕΑ͍ɻ
֎෦ΩʔΛ࣋ͭͱ͍͏͜ͱࢀরઌ ͷσʔλ͕ొ͞Εͳ͍ݶΓɺࢀরݩ ͷσʔλΛొͰ͖ͳ͍ͱ͍͏͜ͱɻ 4. ֎෦Ωʔͷ࣋ͪํ͔ΒσʔλͷϥΠϑαΠΫϧΛߟ͑Δ
֎෦Ωʔͷ࣋ͪํΛؒҧ͑ΔͱΞϓϦέʔγϣ ϯ͔Βͷσʔλొॲཧ͕ෳࡶʹͳͬͨΓɺ Ϣʔβʔͷۀʹଇ͞ͳ͍ػೳʹͳΔ͜ͱͰ ϢʔβϏϦςΟͷԼΛট͘͜ͱʹͳΔɻ ֎෦Ωʔͷ࣋ͪํͷॏཁੑ
Example ݟੵґཔ(request_for_quotations)ʹਤ໘ (diagram_images)Λఴͯ͠ૹ৴͢Δɻ
diagram_images ID name path request_for_quotation_id 1 ਤ໘_ver1 /images/xxxx/sample.jpeg 1 2
ਤ໘_ver2 /images/xxxx/sample2.jpeg 1 3 ਤ໘_ver3 /images/xxxx/sample3.jpeg 2 request_for_quotations ID produce_number 1 300 2 60
diagram_images ID name path request_for_quotation_id 1 ਤ໘_ver1 /images/xxxx/sample.jpeg 1 2
ਤ໘_ver2 /images/xxxx/sample2.jpeg 1 3 ਤ໘_ver3 /images/xxxx/sample3.jpeg 2 request_for_quotations ID produce_number 1 300 2 60 diagram_iamgesඞͣ request_for_quotationsͷ࡞ ޙʹొ͢Δʁ
ۀΛߟ͑Δ 1 ݟੵґཔ࡞લʹઃܭ෦͔Βਤ໘ϑΝΠϧ͚ͩڞ༗͞Ε Δͱ͍͏Ϣʔεέʔε 2 ਤ໘ϑΝΠϧΛΞοϓϩʔυͤͣʹϚελʔͱͯ͠ొ ͓͖ͯ͠ɺݟੵґཔ࣌ʹͦΕΛࢀরར༻͢Δͱ͍͏Ϣ ʔεέʔε
ۀΛߟ͑Δ 1 ݟੵґཔ࡞લʹઃܭ෦͔Βਤ໘ϑΝΠϧ͚ͩڞ༗͞Ε Δͱ͍͏Ϣʔεέʔε 2 ਤ໘ϑΝΠϧΛΞοϓϩʔυͤͣʹϚελʔͱͯ͠ొ ͓͖ͯ͠ɺݟੵґཔ࣌ʹͦΕΛࢀরར༻͢Δͱ͍͏Ϣ ʔεέʔε ඞͣ͠ݟੵґཔ࡞ޙʹਤ໘Λొ͢Δͱ͍͏Θ͚Ͱͳ͍
diagram_images ID name path 1 ਤ໘_ver1 /images/xxxx/sample.jpeg 2 ਤ໘_ver2 /images/xxxx/sample2.jpeg
3 ਤ໘_ver3 /images/xxxx/sample3.jpeg request_for_quotations ID produce_number 1 300 2 60 ID diagram_image_id request_for_quotation_id 1 1 1 2 2 1 3 3 2 attached_diagram_images diagram_imagesͱ request_for_quotationsͷ σʔλొॱෆಉʹͳͬͨ
υϝΠϯΤΩεύʔτ͔ΒͷใͷҾ͖ग़͠ํ ൪֎ฤ
1 ୟ͖ͱͳΔERDΛ࡞Δ 2 ERDͷؔ࿈͝ͱʹυϝΠϯʹదͨ͠ྫΛ༻͍ͳ͕Β࣮ମΛ өͰ͖͍ͯΔ͔υϝΠϯΤΩεύʔτʹ֬ೝ͢Δ
Example ֎෦Ωʔͷ࣋ͪํɺNULLͷՄೳੑɺςʔϒϧ ͷؔ࿈(1:n/1:1/n:n)ʹ͍ͭͯ1ͭͣͭྫΛग़ ͠ͳ͕Βʮ◦◦͕ෳʹͳΔ͜ͱͬͯ͋Γ·͢ ͔ʁʯͱ࣭͍ͯ͘͠ɻ
Example diagram_images ID path request_for_quotation_id 1 /images/xxxx/sample.jpeg 1 2 /images/xxxx/sample2.jpeg
1 3 /images/xxxx/sample3.jpeg 2 request_for_quotations ID produce_number 1 300 2 60
Example diagram_images ID path request_for_quotation_id 1 /images/xxxx/sample.jpeg 1 2 /images/xxxx/sample2.jpeg
1 3 /images/xxxx/sample3.jpeg 2 request_for_quotations ID produce_number 1 300 2 60 ਤ໘ϑΝΠϧͬͯݟੵґཔʹରͯ͠ෳ ఴ͢Δ͜ͱ͋Γ·͔͢ʁ me
Example diagram_images ID path request_for_quotation_id 1 /images/xxxx/sample.jpeg 1 2 /images/xxxx/sample2.jpeg
1 3 /images/xxxx/sample3.jpeg 2 request_for_quotations ID produce_number 1 300 2 60 ݟੵґཔΛ࡞͢Δલʹਤ໘ϑΝΠϧ͚ͩ ଞ෦͔Βڞ༗͞ΕΔ͜ͱ͋Γ·͔͢ʁ me
υϝΠϯΤΩεύʔτͷґཔͷํ υϝΠϯΤΩεύʔτ͔Β͢ΔͱɺʮͳΜͰͦ ΜͳʹΤοδέʔε·Ͱؾʹ͢ΔΜʁʯͱ͍͏ ؾ࣋ͪʹͳΓ͍͢ɻ ͔ͩΒɺʮؾ͍ͯͳ͍Τοδέʔε·Ͱؾͮ ͚Δ͜ͱ͕ࠓޙͷγεςϜ։ൃͷεϐʔυΛ ͘͢Δʯͱ͍͏͜ͱΛ͑ͯɺ͍ΖΜͳέʔε ͷ૾ΛΒ·ͤͯΒ͏Α͏ʹ͢Δɻ
We are hiring!