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
What’s New in Compose Multiplatform - A Live Tour (droidcon London 2024)
zsmb
1
340
Webの技術スタックで マルチプラットフォームアプリ開発を可能にするElixirDesktopの紹介
thehaigo
2
920
qmuntal/stateless のススメ
sgash708
0
120
推し活の ハイトラフィックに立ち向かう Railsとアーキテクチャ - Kaigi on Rails 2024
falcon8823
6
2.2k
Vue3の一歩踏み込んだパフォーマンスチューニング2024
hal_spidernight
3
3.1k
現場で役立つモデリング 超入門
masuda220
PRO
13
2.9k
リリース8年目のサービスの1800個のERBファイルをViewComponentに移行した方法とその結果
katty0324
5
3.6k
JaSST 24 九州:ワークショップ(は除く)実践!マインドマップを活用したソフトウェアテスト+活用事例
satohiroyuki
0
260
アジャイルを支えるテストアーキテクチャ設計/Test Architecting for Agile
goyoki
7
2.8k
Progressive Web Apps für Desktop und Mobile mit Angular (Hands-on)
christianliebel
PRO
0
110
Identifying User Idenity
moro
6
7.9k
【Kaigi on Rails 2024】YOUTRUST スポンサーLT
krpk1900
1
250
Featured
See All Featured
How to Ace a Technical Interview
jacobian
275
23k
BBQ
matthewcrist
85
9.3k
Statistics for Hackers
jakevdp
796
220k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
Speed Design
sergeychernyshev
24
570
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
191
16k
Teambox: Starting and Learning
jrom
132
8.7k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
46
2.1k
Scaling GitHub
holman
458
140k
Building a Scalable Design System with Sketch
lauravandoore
459
33k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
Measuring & Analyzing Core Web Vitals
bluesmoon
1
40
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!