SlideShare a Scribd company logo
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved.
April 2022
Matthew D. Groves | Product Marketing Manager
JSON Data Modeling
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 2
Modeling Data in a Relational World
RDBMS table-based modeling
Billing
Connections
Purchases
Contacts
Customer
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved.
01/
02/
03/
04/
05/
Why NoSQL?
JSON Data Modeling
Accessing Data
Migrating Data
Summary / Q&A
Agenda
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 4
1 Why NoSQL?
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 5
NoSQL Landscape
• Couchbase
• DynamoDB
• CosmosDB
• Redis
• Aerospike
• Couchbase
• MongoDB
• DynamoDB
• CosmosDB
Key-Value Document
• Cassandra
• Hbase
• CosmosDB
• Datastax
• Neo4J
• OrientDB
• CosmosDB
Wide Column Graph
🔑 📄 🔢 🗺
Broad categories, many are "multi-model"
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 6
NoSQL Landscape
• Couchbase
• MongoDB
• DynamoDB
• CosmosDB
Document
📄
Broad categories, many are "multi-model"
• Store data as JSON (or XML, etc)
• Get by key
• Set by key
• Replace by key
• Delete by key
• Query/index
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 7
What's NoSQL?
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 8
Why NoSQL? Scalability
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 9
Why NoSQL? Flexibility
{
"name" : "matt groves"
}
{
"firstName" : "jeff",
"lastName" : "morris"
}
DocumentKey: 120902
DocumentKey: 930912
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 10
Why NoSQL? Availability
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 11
Why NoSQL? Fast
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 12
Use Cases for NoSQL
• Caching
• Session
• User profile
• Catalog
• Content management
• Personalization
• Customer 360
• IoT
• Inventory
• Communication
• Gaming
• Advertising
• Travel booking
• Loyalty programs
• Fraud monitoring
• Social media
• Finance
• Health Care
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 13
Use Cases
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 14
2 JSON Data Modeling
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 15
Properties of Real-World Data
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 16
Modeling Data in a Relational World
RDBMS table-based modeling
Billing
Connections
Purchases
Contacts
Customer
CustomerID Name DOB
CBL2015 Jane
Smith
1990-01-30
Table: Customer
{
"Name" : "Jane Smith",
"DOB" : "1990-01-30”
}
Customer Document
Key: CBL2015
©2017 Couchbase Inc. 18
CustomerID Name DOB
CBL2015 Jane
Smith
1990-01-30
Table: Customer
{
"Name" : "Jane Smith",
"DOB" : "1990-01-30",
"Purchases" : [
{
"item" : "laptop",
"amount" : 1499.99,
"date" : "2019-03",
}
]
}
Customer Document
Key: CBL2015
CustomerID Item Amount Date
CBL2015 laptop 1499.99 2019-03
Table: Purchases
CustomerID Name DOB
CBL2015 Jane
Smith
1990-01-30
Table: Customer
{
"Name" : "Jane Smith",
"DOB" : "1990-01-30",
"Purchases" : [
{
"item" : "laptop",
"amount" : 1499.99,
"date" : "2019-03",
},
{
"item" : "phone",
"amount" : 99.99,
"date" : "2018-12"
}
]
}
Customer Document
Key: CBL2015
CustomerID Item Amount Date
CBL2015 laptop 1499.99 2019-03
CBL2015 phone 99.99 2018-12
Table: Purchases
CustomerID ConnId Relation
CBL2015 XYZ987 Brother
CBL2015 SKR007 Father
Table: Connections
{
"Name" : "Jane Smith",
"DOB" : "1990-01-30",
"Billing" : [
{
"type" : "visa",
"cardnum" : "5827-2842-...",
"expiry" : "2019-03"
}, ...
],
"Connections" : [
{
"ConnId" : "XYZ987",
"Relation" : "Brother"
},
{
"ConnId" : "SKR007",
"Relation" : "Father"
}
}
Customer Document
Key: CBL2015
©2017 Couchbase Inc. 21
{
"Name" : "Jane Smith",
"DOB" : "1990-01-30",
"cardnum" : "5827-2842…",
"expiry" : "2019-03",
"cardType" : "visa",
"Connections" : [
{
"CustId" : "XYZ987",
"Relation" : "Brother"
},
{
"CustId" : "SKR007",
"Relation" : "Father"
}
],
"Purchases" : [
{ "id":12, item: "mac", "amt": 2823.52 }
{ "id":19, item: "ipad2", "amt": 623.52 }
]
}
Customer Document
Key: CBL2015
CustomerID Name DOB Cardnum Expiry CardType
CBL2015 Jane
Smith
1990-01-30 5827-2842… 2019-03 visa
CustomerID ConnId Relation
CBL2015 XYZ987 Brother
CBL2015 SKR007 Father
CustomerID item amt
CBL2015 mac 2823.52
CBL2015 ipad2 623.52
CustomerID ConnId Name
CBL2015 XYZ987 Joe
Smith
CBL2015 SKR007 Sam
Smith
Contacts
Customer
Connections
Purchases
{
"Name" : "Bob Jones",
"DOB" : "1980-01-29",
"Billing" : [
{
"type" : "visa",
"cardnum" : "5927-2842-2847-3909",
"expiry" : "2020-03"
},
{
"type" : "master",
"cardnum" : "6273-2842-2847-3909",
"expiry" : "2019-11"
}
],
"Connections" : [
{
"CustId" : "XYZ987",
"Relation" : "Brother"
},
{
"CustId" : "PQR823",
"Relation" : "Father"
}
],
"Purchases" : [
{ "id":12, item: "mac", "amt": 2823.52 },
{ "id":19, item: "ipad2", "amt": 623.52 }
]
}
Customer Document
Key: CBL2016
CustomerID Name DOB
CBL2016 Bob Jones 1980-01-29
CustomerID Type Cardnum Expiry
CBL2016 visa 5927… 2020-03
CBL2016 master 6273… 2019-11
CustomerID ConnId Relation
CBL2016 XYZ987 Brother
CBL2016 SKR007 Father
CustomerID item amt
CBL2016 mac 2823.52
CBL2016 ipad2 623.52
CustomerID ConnI
d
Name
CBL2016 XYZ987 Joe
Smith
CBL2016 SKR007 Sam
Smith
Contacts
Customer
Billing
Connections
Purchases
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 23
Versioning approach 1: Version Numbers
{
"name" : "matt groves"
"version" : 1
}
{
"firstName" : "jeff",
"lastName" : "morris",
"version" : 2
}
Document Key:
120902
Document Key:
930912
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 24
Versioning approach 2: Big Bang Re-versioning
{
"name" : "matt groves"
}
{
"firstName" : "matt",
"lastName" : "groves
}
Document Key:
120902
Document Key:
120902
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 25
Versioning approach 3: Cooperative Re-versioning
{
"name" : "matt groves"
}
{
"firstName" : "matt",
"lastName" : "groves",
}
DocumentKey: 120902
DocumentKey: 120902
Web application
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 26
Modeling tools
• Hackolade
• Erwin DM NoSQL
• https://jsoneditoronline.org
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 27
3 Accessing Data
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 28
Key/Value
public async Task<ShoppingCart> GetCartById(string id)
{
var cart = await _collection.GetAsync(id);
return cart.ContentAs<ShoppingCart>();
}
public async Task CreateShoppingCart()
{
await _collection.InsertAsync(
Guid.NewGuid().ToString(),
new ShoppingCart { . . . }
);
}
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 29
Key/Value: Recommendations for keys
• Natural Keys
• Account number, driver license number, ISBN
• Human Readable
• "user-123" vs "0be12ae9-1b1d-4724-9706-2977cc134daf"
• Deterministic
• "matt" -> "matt::blogs" -> "blog::csharp_9_features"
• Semantic
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 30
Key/Value: Example keys
1. User logs in with username and password
• Lookup "author::<username>" in the database
2. Once logged in, save username to session state.
3. User wants to view their blogs.
• Lookup "author::<username>::blogs" in the database
4. Document contains list of "slugs"
5. User wants to view a specific blog.
• Lookup "blog::<slug>" in the database
6. User wants to view all comments for this post
• Lookup "blog::<slug>::comments" in the database
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 31
Modeling your data: Strategies / rules of thumb
• Relationship is one-to-one or one-
to-many
• Store related data as nested
objects
{
"Name" : "Jane Smith",
"DOB" : "1990-01-30",
"Purchases" : [
{
"item" : "laptop",
"amount" : 1499.99,
"date" : "2019-03",
},
{
"item" : "phone",
"amount" : 99.99,
"date" : "2018-12"
}
]
}
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 32
Modeling your data: Strategies / rules of thumb
• Relationship is many-to-one or
many-to-many
• Store related data as separate
documents
{
"Name" : "Jane Smith",
"DOB" : "1990-01-30",
"Connections" : [
"XYZ987",
"PQR823",
"PQR828"
]
}
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 33
Modeling your data: Strategies / rules of thumb
• Data reads are mostly parent fields
• Store children as separate
documents
{
"Name" : "Jane Smith",
"DOB" : "1990-01-30",
"Connections" : [
"XYZ987",
"PQR823",
"PQR828"
]
}
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 34
Modeling your data: Strategies / rules of thumb
• Data reads are mostly parent +
child fields
• Store children as nested objects
{
"Name" : "Jane Smith",
"DOB" : "1990-01-30",
"Purchases" : [
{
"item" : "laptop",
"amount" : 1499.99,
"date" : "2019-03",
},
{
"item" : "phone",
"amount" : 99.99,
"date" : "2018-12"
}
]
}
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 35
Modeling your data: Strategies / rules of thumb
• Data writes are mostly parent or
child (not both)
• Store children as separate
documents
{
"Name" : "Jane Smith",
"DOB" : "1990-01-30",
"Connections" : [
"XYZ987",
"PQR823",
"PQR828"
]
}
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 36
Modeling your data: Strategies / rules of thumb
• Data writes are mostly parent and
child (both)
• Store children as nested objects
{
"Name" : "Jane Smith",
"DOB" : "1990-01-30",
"Purchases" : [
{
"item" : "laptop",
"amount" : 1499.99,
"date" : "2019-03",
},
{
"item" : "phone",
"amount" : 99.99,
"date" : "2018-12"
}
]
}
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 37
Modeling your data: Strategies / rules of thumb
If … Then …
Relationship is one-to-one or one-to-many Store related data as nested objects
Relationship is many-to-one or many-to-many Store related data as separate documents
Data reads are mostly parent fields Store children as separate documents
Data reads are mostly parent + child fields Store children as nested objects
Data writes are mostly parent or child (not
both)
Store children as separate documents
Data writes are mostly parent and child (both) Store children as nested objects
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 38
Subdocument access
{
"username": "mgroves",
"profile": {
"phoneNumber": "123-456-7890",
"address": {
"street": "123 main st",
"city": "Grove City",
"state": "Ohio"
}
}
}
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 39
Other ways to access data (Couchbase)
Key-Value
(CRUD)
SQL++
(SQL Query)
Full Text
(Search)
Documents
Indexes Indexes
Mobile
(iOS/
Android)
Analytics
(Query)
Sync
Gateway
SQL++
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 40
SQL++
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 41
Understanding your Query Plan
"recommended_indexes": {
"indexes": [{
"index_statement":
"CREATE INDEX adv_name ON `default`:`travel-sample`.`inventory`.`airline`(`name`)",
"keyspace_alias": "airline_a",
"recommending_rule": "Index keys follow order of predicate types: 8. like."
}]
}
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 42
Full Text Search
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 43
Accessing your data
Strategies and recommendations
Concept Strategies & Recommendations
Key-Value Operations provide the best
possible performance
• Create an effective key naming strategy
• Create an optimized data model
Full Text Search is well-suited to text • Facets / ranges / geography
• Language aware
• Inverted index
N1QL queries provide the most flexibility –
everything else
• Query data regardless of how it is modeled
• Good indexing is vital
• B-Tree
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 44
4 Migrating Data
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 45
How do you migrate?
A spectrum of approaches
1. Rewrite: No migration, write the whole thing over
2. Redesign Schema: Keep your business logic, rewrite your data
layer and schema, totally redesign your schema with a NoSQL-
optimized model
3. Refactor First: Keep everything but refactor your data logic
and RDBMS schema into a NoSQL-optimized model
4. Optimize Later: Host your schema with as few changes as
possible, get the application running on the new technology,
refactor/optimize the schema as necessary for performance
5. Just Host It: Host your schema with as few changes as
possible.
Risk
Effort
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 46
Migration options
Tools
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 47
Migration options
Build Your Own (BYO)
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 48
Migration options: KISS (level 5)
"Level 5" = "Just Host it"
Export
Transform
Import
NoSQL (optimized)
Relational
NoSQL
(raw)
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 49
Migration options
KISS (levels 4,3,2)
Export
Transform
Import
NoSQL
Relational
NoSQL (optimized)
"staging"
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 50
Migration Recommendations
Alignment
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 51
SqlServerToCouchbase Demo
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 52
5 Summary
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved.
Pick the right
application
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved.
Proof of Concept
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved.
Match the data
access method to
requirements
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 56
Next Steps
• Couchbase playground:
• https://couchbase.live
• Couchbase Capella free trial:
• https://cloud.couchbase.com/sign-up
• SqlServerToCouchbase:
• https://github.com/mgroves/SqlServerToCouchbase

More Related Content

PDF
The ABCs of Treating Data as Product
PDF
Best Practices in Metadata Management
PPT
Gartner: Master Data Management Functionality
PDF
Data Architecture Strategies: Data Architecture for Digital Transformation
PDF
DAS Slides: Data Governance - Combining Data Management with Organizational ...
PDF
Building a Data Governance Strategy
PDF
Emerging Trends in Data Architecture – What’s the Next Big Thing?
PDF
Best Practices in Metadata Management
The ABCs of Treating Data as Product
Best Practices in Metadata Management
Gartner: Master Data Management Functionality
Data Architecture Strategies: Data Architecture for Digital Transformation
DAS Slides: Data Governance - Combining Data Management with Organizational ...
Building a Data Governance Strategy
Emerging Trends in Data Architecture – What’s the Next Big Thing?
Best Practices in Metadata Management

What's hot (20)

PDF
Glossaries, Dictionaries, and Catalogs Result in Data Governance
PDF
How to Strengthen Enterprise Data Governance with Data Quality
PDF
Activate Data Governance Using the Data Catalog
PDF
How to identify the correct Master Data subject areas & tooling for your MDM...
PDF
Data Quality Best Practices
PPTX
The Business Glossary, Data Dictionary, Data Catalog Trifecta
PDF
Data Catalog for Better Data Discovery and Governance
PDF
Data strategy demistifying data
PDF
The Death of the Star Schema
PDF
Building an integrated data strategy
PPT
MDM and Reference Data
PDF
Why data governance is the new buzz?
PDF
Data Catalogs Are the Answer – What is the Question?
PDF
Improving Data Literacy Around Data Architecture
PDF
Data Governance Takes a Village (So Why is Everyone Hiding?)
PPT
Data Governance
PDF
Mdm: why, when, how
PDF
Databricks: A Tool That Empowers You To Do More With Data
PDF
Selecting Data Management Tools - A practical approach
PPTX
Enterprise Data Management
Glossaries, Dictionaries, and Catalogs Result in Data Governance
How to Strengthen Enterprise Data Governance with Data Quality
Activate Data Governance Using the Data Catalog
How to identify the correct Master Data subject areas & tooling for your MDM...
Data Quality Best Practices
The Business Glossary, Data Dictionary, Data Catalog Trifecta
Data Catalog for Better Data Discovery and Governance
Data strategy demistifying data
The Death of the Star Schema
Building an integrated data strategy
MDM and Reference Data
Why data governance is the new buzz?
Data Catalogs Are the Answer – What is the Question?
Improving Data Literacy Around Data Architecture
Data Governance Takes a Village (So Why is Everyone Hiding?)
Data Governance
Mdm: why, when, how
Databricks: A Tool That Empowers You To Do More With Data
Selecting Data Management Tools - A practical approach
Enterprise Data Management
Ad

Similar to JSON Data Modeling in Document Database (20)

PPTX
JSON Data Modeling - GDG Indy - April 2020
PPTX
Json data modeling june 2017 - pittsburgh tech fest
PDF
Data Modeling and Relational to NoSQL
PPTX
Bringing SQL to NoSQL: Rich, Declarative Query for NoSQL
PPTX
Putting the SQL Back in NoSQL - October 2022 - All Things Open
PPTX
JSON Data Modeling - July 2018 - Tulsa Techfest
PDF
Slides: Moving from a Relational Model to NoSQL
PDF
The Why, When, and How of NoSQL - A Practical Approach
PDF
Slides: NoSQL Data Modeling Using JSON Documents – A Practical Approach
PPTX
Querying NoSQL with SQL - MIGANG - July 2017
PDF
Three Things You Need to Know About Document Data Modeling in NoSQL
PPTX
SQL for JSON: Rich, Declarative Querying for NoSQL Databases and Applications 
PPTX
Introducing N1QL: New SQL Based Query Language for JSON
PPTX
Query in Couchbase. N1QL: SQL for JSON
PPTX
NoSQL Data Modeling using Couchbase
PPTX
Querying NoSQL with SQL - KCDC - August 2017
PPTX
Characteristics of no sql databases
PDF
Migration and Coexistence between Relational and NoSQL Databases by Manuel H...
PDF
Couchbase Overview Nov 2013
PPTX
Couchbase Overview - Monterey Bay Information Technologists Meetup 02.15.17
JSON Data Modeling - GDG Indy - April 2020
Json data modeling june 2017 - pittsburgh tech fest
Data Modeling and Relational to NoSQL
Bringing SQL to NoSQL: Rich, Declarative Query for NoSQL
Putting the SQL Back in NoSQL - October 2022 - All Things Open
JSON Data Modeling - July 2018 - Tulsa Techfest
Slides: Moving from a Relational Model to NoSQL
The Why, When, and How of NoSQL - A Practical Approach
Slides: NoSQL Data Modeling Using JSON Documents – A Practical Approach
Querying NoSQL with SQL - MIGANG - July 2017
Three Things You Need to Know About Document Data Modeling in NoSQL
SQL for JSON: Rich, Declarative Querying for NoSQL Databases and Applications 
Introducing N1QL: New SQL Based Query Language for JSON
Query in Couchbase. N1QL: SQL for JSON
NoSQL Data Modeling using Couchbase
Querying NoSQL with SQL - KCDC - August 2017
Characteristics of no sql databases
Migration and Coexistence between Relational and NoSQL Databases by Manuel H...
Couchbase Overview Nov 2013
Couchbase Overview - Monterey Bay Information Technologists Meetup 02.15.17
Ad

More from DATAVERSITY (20)

PDF
Architecture, Products, and Total Cost of Ownership of the Leading Machine Le...
PDF
Data at the Speed of Business with Data Mastering and Governance
PDF
Exploring Levels of Data Literacy
PDF
Building a Data Strategy – Practical Steps for Aligning with Business Goals
PDF
Make Data Work for You
PDF
Data Catalogs Are the Answer – What Is the Question?
PDF
Data Modeling Fundamentals
PDF
Showing ROI for Your Analytic Project
PDF
How a Semantic Layer Makes Data Mesh Work at Scale
PDF
Is Enterprise Data Literacy Possible?
PDF
The Data Trifecta – Privacy, Security & Governance Race from Reactivity to Re...
PDF
Emerging Trends in Data Architecture – What’s the Next Big Thing?
PDF
Data Governance Trends - A Look Backwards and Forwards
PDF
Data Governance Trends and Best Practices To Implement Today
PDF
2023 Trends in Enterprise Analytics
PDF
Data Strategy Best Practices
PDF
Who Should Own Data Governance – IT or Business?
PDF
Data Management Best Practices
PDF
MLOps – Applying DevOps to Competitive Advantage
PDF
Keeping the Pulse of Your Data – Why You Need Data Observability to Improve D...
Architecture, Products, and Total Cost of Ownership of the Leading Machine Le...
Data at the Speed of Business with Data Mastering and Governance
Exploring Levels of Data Literacy
Building a Data Strategy – Practical Steps for Aligning with Business Goals
Make Data Work for You
Data Catalogs Are the Answer – What Is the Question?
Data Modeling Fundamentals
Showing ROI for Your Analytic Project
How a Semantic Layer Makes Data Mesh Work at Scale
Is Enterprise Data Literacy Possible?
The Data Trifecta – Privacy, Security & Governance Race from Reactivity to Re...
Emerging Trends in Data Architecture – What’s the Next Big Thing?
Data Governance Trends - A Look Backwards and Forwards
Data Governance Trends and Best Practices To Implement Today
2023 Trends in Enterprise Analytics
Data Strategy Best Practices
Who Should Own Data Governance – IT or Business?
Data Management Best Practices
MLOps – Applying DevOps to Competitive Advantage
Keeping the Pulse of Your Data – Why You Need Data Observability to Improve D...

Recently uploaded (20)

PPTX
ALIMENTARY AND BILIARY CONDITIONS 3-1.pptx
PPTX
oil_refinery_comprehensive_20250804084928 (1).pptx
PDF
Clinical guidelines as a resource for EBP(1).pdf
PPTX
Introduction to Basics of Ethical Hacking and Penetration Testing -Unit No. 1...
PDF
Recruitment and Placement PPT.pdfbjfibjdfbjfobj
PPTX
Supervised vs unsupervised machine learning algorithms
PPTX
Business Ppt On Nestle.pptx huunnnhhgfvu
PPT
Reliability_Chapter_ presentation 1221.5784
PDF
“Getting Started with Data Analytics Using R – Concepts, Tools & Case Studies”
PPTX
Data_Analytics_and_PowerBI_Presentation.pptx
PDF
.pdf is not working space design for the following data for the following dat...
PPTX
1_Introduction to advance data techniques.pptx
PDF
TRAFFIC-MANAGEMENT-AND-ACCIDENT-INVESTIGATION-WITH-DRIVING-PDF-FILE.pdf
PPTX
climate analysis of Dhaka ,Banglades.pptx
PDF
Data Science Trends & Career Guide---ppt
PPTX
CEE 2 REPORT G7.pptxbdbshjdgsgjgsjfiuhsd
PPTX
DISORDERS OF THE LIVER, GALLBLADDER AND PANCREASE (1).pptx
PPT
Chapter 2 METAL FORMINGhhhhhhhjjjjmmmmmmmmm
PDF
Foundation of Data Science unit number two notes
PPTX
STUDY DESIGN details- Lt Col Maksud (21).pptx
ALIMENTARY AND BILIARY CONDITIONS 3-1.pptx
oil_refinery_comprehensive_20250804084928 (1).pptx
Clinical guidelines as a resource for EBP(1).pdf
Introduction to Basics of Ethical Hacking and Penetration Testing -Unit No. 1...
Recruitment and Placement PPT.pdfbjfibjdfbjfobj
Supervised vs unsupervised machine learning algorithms
Business Ppt On Nestle.pptx huunnnhhgfvu
Reliability_Chapter_ presentation 1221.5784
“Getting Started with Data Analytics Using R – Concepts, Tools & Case Studies”
Data_Analytics_and_PowerBI_Presentation.pptx
.pdf is not working space design for the following data for the following dat...
1_Introduction to advance data techniques.pptx
TRAFFIC-MANAGEMENT-AND-ACCIDENT-INVESTIGATION-WITH-DRIVING-PDF-FILE.pdf
climate analysis of Dhaka ,Banglades.pptx
Data Science Trends & Career Guide---ppt
CEE 2 REPORT G7.pptxbdbshjdgsgjgsjfiuhsd
DISORDERS OF THE LIVER, GALLBLADDER AND PANCREASE (1).pptx
Chapter 2 METAL FORMINGhhhhhhhjjjjmmmmmmmmm
Foundation of Data Science unit number two notes
STUDY DESIGN details- Lt Col Maksud (21).pptx

JSON Data Modeling in Document Database

  • 1. Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. April 2022 Matthew D. Groves | Product Marketing Manager JSON Data Modeling
  • 2. Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 2 Modeling Data in a Relational World RDBMS table-based modeling Billing Connections Purchases Contacts Customer
  • 3. Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 01/ 02/ 03/ 04/ 05/ Why NoSQL? JSON Data Modeling Accessing Data Migrating Data Summary / Q&A Agenda
  • 4. Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 4 1 Why NoSQL?
  • 5. Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 5 NoSQL Landscape • Couchbase • DynamoDB • CosmosDB • Redis • Aerospike • Couchbase • MongoDB • DynamoDB • CosmosDB Key-Value Document • Cassandra • Hbase • CosmosDB • Datastax • Neo4J • OrientDB • CosmosDB Wide Column Graph 🔑 📄 🔢 🗺 Broad categories, many are "multi-model"
  • 6. Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 6 NoSQL Landscape • Couchbase • MongoDB • DynamoDB • CosmosDB Document 📄 Broad categories, many are "multi-model" • Store data as JSON (or XML, etc) • Get by key • Set by key • Replace by key • Delete by key • Query/index
  • 7. Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 7 What's NoSQL?
  • 8. Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 8 Why NoSQL? Scalability
  • 9. Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 9 Why NoSQL? Flexibility { "name" : "matt groves" } { "firstName" : "jeff", "lastName" : "morris" } DocumentKey: 120902 DocumentKey: 930912
  • 10. Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 10 Why NoSQL? Availability
  • 11. Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 11 Why NoSQL? Fast
  • 12. Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 12 Use Cases for NoSQL • Caching • Session • User profile • Catalog • Content management • Personalization • Customer 360 • IoT • Inventory • Communication • Gaming • Advertising • Travel booking • Loyalty programs • Fraud monitoring • Social media • Finance • Health Care
  • 13. Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 13 Use Cases
  • 14. Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 14 2 JSON Data Modeling
  • 15. Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 15 Properties of Real-World Data
  • 16. Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 16 Modeling Data in a Relational World RDBMS table-based modeling Billing Connections Purchases Contacts Customer
  • 17. CustomerID Name DOB CBL2015 Jane Smith 1990-01-30 Table: Customer { "Name" : "Jane Smith", "DOB" : "1990-01-30” } Customer Document Key: CBL2015
  • 18. ©2017 Couchbase Inc. 18 CustomerID Name DOB CBL2015 Jane Smith 1990-01-30 Table: Customer { "Name" : "Jane Smith", "DOB" : "1990-01-30", "Purchases" : [ { "item" : "laptop", "amount" : 1499.99, "date" : "2019-03", } ] } Customer Document Key: CBL2015 CustomerID Item Amount Date CBL2015 laptop 1499.99 2019-03 Table: Purchases
  • 19. CustomerID Name DOB CBL2015 Jane Smith 1990-01-30 Table: Customer { "Name" : "Jane Smith", "DOB" : "1990-01-30", "Purchases" : [ { "item" : "laptop", "amount" : 1499.99, "date" : "2019-03", }, { "item" : "phone", "amount" : 99.99, "date" : "2018-12" } ] } Customer Document Key: CBL2015 CustomerID Item Amount Date CBL2015 laptop 1499.99 2019-03 CBL2015 phone 99.99 2018-12 Table: Purchases
  • 20. CustomerID ConnId Relation CBL2015 XYZ987 Brother CBL2015 SKR007 Father Table: Connections { "Name" : "Jane Smith", "DOB" : "1990-01-30", "Billing" : [ { "type" : "visa", "cardnum" : "5827-2842-...", "expiry" : "2019-03" }, ... ], "Connections" : [ { "ConnId" : "XYZ987", "Relation" : "Brother" }, { "ConnId" : "SKR007", "Relation" : "Father" } } Customer Document Key: CBL2015
  • 21. ©2017 Couchbase Inc. 21 { "Name" : "Jane Smith", "DOB" : "1990-01-30", "cardnum" : "5827-2842…", "expiry" : "2019-03", "cardType" : "visa", "Connections" : [ { "CustId" : "XYZ987", "Relation" : "Brother" }, { "CustId" : "SKR007", "Relation" : "Father" } ], "Purchases" : [ { "id":12, item: "mac", "amt": 2823.52 } { "id":19, item: "ipad2", "amt": 623.52 } ] } Customer Document Key: CBL2015 CustomerID Name DOB Cardnum Expiry CardType CBL2015 Jane Smith 1990-01-30 5827-2842… 2019-03 visa CustomerID ConnId Relation CBL2015 XYZ987 Brother CBL2015 SKR007 Father CustomerID item amt CBL2015 mac 2823.52 CBL2015 ipad2 623.52 CustomerID ConnId Name CBL2015 XYZ987 Joe Smith CBL2015 SKR007 Sam Smith Contacts Customer Connections Purchases
  • 22. { "Name" : "Bob Jones", "DOB" : "1980-01-29", "Billing" : [ { "type" : "visa", "cardnum" : "5927-2842-2847-3909", "expiry" : "2020-03" }, { "type" : "master", "cardnum" : "6273-2842-2847-3909", "expiry" : "2019-11" } ], "Connections" : [ { "CustId" : "XYZ987", "Relation" : "Brother" }, { "CustId" : "PQR823", "Relation" : "Father" } ], "Purchases" : [ { "id":12, item: "mac", "amt": 2823.52 }, { "id":19, item: "ipad2", "amt": 623.52 } ] } Customer Document Key: CBL2016 CustomerID Name DOB CBL2016 Bob Jones 1980-01-29 CustomerID Type Cardnum Expiry CBL2016 visa 5927… 2020-03 CBL2016 master 6273… 2019-11 CustomerID ConnId Relation CBL2016 XYZ987 Brother CBL2016 SKR007 Father CustomerID item amt CBL2016 mac 2823.52 CBL2016 ipad2 623.52 CustomerID ConnI d Name CBL2016 XYZ987 Joe Smith CBL2016 SKR007 Sam Smith Contacts Customer Billing Connections Purchases
  • 23. Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 23 Versioning approach 1: Version Numbers { "name" : "matt groves" "version" : 1 } { "firstName" : "jeff", "lastName" : "morris", "version" : 2 } Document Key: 120902 Document Key: 930912
  • 24. Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 24 Versioning approach 2: Big Bang Re-versioning { "name" : "matt groves" } { "firstName" : "matt", "lastName" : "groves } Document Key: 120902 Document Key: 120902
  • 25. Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 25 Versioning approach 3: Cooperative Re-versioning { "name" : "matt groves" } { "firstName" : "matt", "lastName" : "groves", } DocumentKey: 120902 DocumentKey: 120902 Web application
  • 26. Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 26 Modeling tools • Hackolade • Erwin DM NoSQL • https://jsoneditoronline.org
  • 27. Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 27 3 Accessing Data
  • 28. Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 28 Key/Value public async Task<ShoppingCart> GetCartById(string id) { var cart = await _collection.GetAsync(id); return cart.ContentAs<ShoppingCart>(); } public async Task CreateShoppingCart() { await _collection.InsertAsync( Guid.NewGuid().ToString(), new ShoppingCart { . . . } ); }
  • 29. Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 29 Key/Value: Recommendations for keys • Natural Keys • Account number, driver license number, ISBN • Human Readable • "user-123" vs "0be12ae9-1b1d-4724-9706-2977cc134daf" • Deterministic • "matt" -> "matt::blogs" -> "blog::csharp_9_features" • Semantic
  • 30. Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 30 Key/Value: Example keys 1. User logs in with username and password • Lookup "author::<username>" in the database 2. Once logged in, save username to session state. 3. User wants to view their blogs. • Lookup "author::<username>::blogs" in the database 4. Document contains list of "slugs" 5. User wants to view a specific blog. • Lookup "blog::<slug>" in the database 6. User wants to view all comments for this post • Lookup "blog::<slug>::comments" in the database
  • 31. Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 31 Modeling your data: Strategies / rules of thumb • Relationship is one-to-one or one- to-many • Store related data as nested objects { "Name" : "Jane Smith", "DOB" : "1990-01-30", "Purchases" : [ { "item" : "laptop", "amount" : 1499.99, "date" : "2019-03", }, { "item" : "phone", "amount" : 99.99, "date" : "2018-12" } ] }
  • 32. Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 32 Modeling your data: Strategies / rules of thumb • Relationship is many-to-one or many-to-many • Store related data as separate documents { "Name" : "Jane Smith", "DOB" : "1990-01-30", "Connections" : [ "XYZ987", "PQR823", "PQR828" ] }
  • 33. Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 33 Modeling your data: Strategies / rules of thumb • Data reads are mostly parent fields • Store children as separate documents { "Name" : "Jane Smith", "DOB" : "1990-01-30", "Connections" : [ "XYZ987", "PQR823", "PQR828" ] }
  • 34. Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 34 Modeling your data: Strategies / rules of thumb • Data reads are mostly parent + child fields • Store children as nested objects { "Name" : "Jane Smith", "DOB" : "1990-01-30", "Purchases" : [ { "item" : "laptop", "amount" : 1499.99, "date" : "2019-03", }, { "item" : "phone", "amount" : 99.99, "date" : "2018-12" } ] }
  • 35. Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 35 Modeling your data: Strategies / rules of thumb • Data writes are mostly parent or child (not both) • Store children as separate documents { "Name" : "Jane Smith", "DOB" : "1990-01-30", "Connections" : [ "XYZ987", "PQR823", "PQR828" ] }
  • 36. Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 36 Modeling your data: Strategies / rules of thumb • Data writes are mostly parent and child (both) • Store children as nested objects { "Name" : "Jane Smith", "DOB" : "1990-01-30", "Purchases" : [ { "item" : "laptop", "amount" : 1499.99, "date" : "2019-03", }, { "item" : "phone", "amount" : 99.99, "date" : "2018-12" } ] }
  • 37. Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 37 Modeling your data: Strategies / rules of thumb If … Then … Relationship is one-to-one or one-to-many Store related data as nested objects Relationship is many-to-one or many-to-many Store related data as separate documents Data reads are mostly parent fields Store children as separate documents Data reads are mostly parent + child fields Store children as nested objects Data writes are mostly parent or child (not both) Store children as separate documents Data writes are mostly parent and child (both) Store children as nested objects
  • 38. Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 38 Subdocument access { "username": "mgroves", "profile": { "phoneNumber": "123-456-7890", "address": { "street": "123 main st", "city": "Grove City", "state": "Ohio" } } }
  • 39. Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 39 Other ways to access data (Couchbase) Key-Value (CRUD) SQL++ (SQL Query) Full Text (Search) Documents Indexes Indexes Mobile (iOS/ Android) Analytics (Query) Sync Gateway SQL++
  • 40. Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 40 SQL++
  • 41. Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 41 Understanding your Query Plan "recommended_indexes": { "indexes": [{ "index_statement": "CREATE INDEX adv_name ON `default`:`travel-sample`.`inventory`.`airline`(`name`)", "keyspace_alias": "airline_a", "recommending_rule": "Index keys follow order of predicate types: 8. like." }] }
  • 42. Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 42 Full Text Search
  • 43. Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 43 Accessing your data Strategies and recommendations Concept Strategies & Recommendations Key-Value Operations provide the best possible performance • Create an effective key naming strategy • Create an optimized data model Full Text Search is well-suited to text • Facets / ranges / geography • Language aware • Inverted index N1QL queries provide the most flexibility – everything else • Query data regardless of how it is modeled • Good indexing is vital • B-Tree
  • 44. Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 44 4 Migrating Data
  • 45. Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 45 How do you migrate? A spectrum of approaches 1. Rewrite: No migration, write the whole thing over 2. Redesign Schema: Keep your business logic, rewrite your data layer and schema, totally redesign your schema with a NoSQL- optimized model 3. Refactor First: Keep everything but refactor your data logic and RDBMS schema into a NoSQL-optimized model 4. Optimize Later: Host your schema with as few changes as possible, get the application running on the new technology, refactor/optimize the schema as necessary for performance 5. Just Host It: Host your schema with as few changes as possible. Risk Effort
  • 46. Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 46 Migration options Tools
  • 47. Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 47 Migration options Build Your Own (BYO)
  • 48. Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 48 Migration options: KISS (level 5) "Level 5" = "Just Host it" Export Transform Import NoSQL (optimized) Relational NoSQL (raw)
  • 49. Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 49 Migration options KISS (levels 4,3,2) Export Transform Import NoSQL Relational NoSQL (optimized) "staging"
  • 50. Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 50 Migration Recommendations Alignment
  • 51. Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 51 SqlServerToCouchbase Demo
  • 52. Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 52 5 Summary
  • 53. Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. Pick the right application
  • 54. Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. Proof of Concept
  • 55. Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. Match the data access method to requirements
  • 56. Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2021. All rights reserved. 56 Next Steps • Couchbase playground: • https://couchbase.live • Couchbase Capella free trial: • https://cloud.couchbase.com/sign-up • SqlServerToCouchbase: • https://github.com/mgroves/SqlServerToCouchbase