SlideShare a Scribd company logo
Presented by Matthew D. Groves
Data Modeling and
Relational to NoSQL
2
Couchbase: The Modern NoSQL Database
Sub-millisecond
performance
Simplicity & Scalability
UC: Caching, Cart, IOT,
User Profiles & Sessions
Compare with:
Redis, Elasticache,
Aerospike
Flexible JSON schema
easily maps to RDBMS
N1QL is SQL for JSON
UC: Content Management,
Catalog, Metadata,
Customer 360
Compare with:
DynamoDB, MongoDB,
CosmosDB
No ETL, SQL++, MPP
Workload Isolation
UC: Real-time Insights,
Fraud detection, AI,
Recommendation engines
Compare with:
MemSQL, CockroachDB,
Hana
Full-text Search
Inverted Index
UC: Log analysis,
Collaboration, Website
Search
Compare with:
Elasticsearch, Solr,
Lucene
Cloud to Edge Sync
Peer to Peer Sync
UC: Field Apps, Airplanes,
Ships, Retail Stores,
Restaurants, IOT Apps
Compare with:
Realm, SQLite,
Berkeley DB
Key-Value Store Document Database Analytics
HTAP/HOAP
Search Engine
Edge Database
3
Are These Your Goals?
• Identify a use case that can benefit from a modern database
• Get some/all of data on to a modern database
• Switch your application / Build a new application
• Optimize your data model / access
01/
02/
03/
Mapping from relational
Shift Application Code
Optimize
Agenda
5
1 Mapping from relational
6
Why now?
• Couchbase 7.0 / Couchbase Capella
• Scopes / collections
• ACID Transactions
• N1QL (SQL++)
7
So, is Couchbase a relational database now?
• Distributed
• Highly available
• Flexible
• Memory-first
8
SQL-to-Couchbase Dictionary
Legacy (relational) Modern (Couchbase) Notes
Server Cluster ➕ Scalability / High Availability
Database Bucket ➕ Replication / Caching
Schema Scope "dbo" and "_default"
Table Collection ➕ Flexibility
Row Document ➕ JSON
tSQL (SQL) N1QL (SQL++) Full SQL implementation with: SELECT, JOIN, COMMIT,
ROLLBACK, GROUP BY, INSERT, etc…
Primary Key Document Key
Index Index
9
SqlToCouchbase Library
10
Other Options/Tools
• GlueSync - https://gluesync.com/
• Built by partner MOLO17
• Real-time sync between Couchbase and SQL Server / Oracle
• Couchgres - https://github.com/metonymic-smokey/couchgres
• Open source community project
• Migrate from Postgres to Couchbase
• Python script - https://bit.ly/mysqlPython
• Bare-bones, script-based approach
• Import CSV via UI
11
Demo: Mapping
12
2 Shift Application Code
13
What do I need to shift?
• SDK – connecting to the database
• SQL – querying the database
• ACID Transactions – updating data reliably
14
SELECT RTRIM(p.FirstName) + ' ' + LTRIM(p.LastName) AS Name, d.City
FROM AdventureWorks2016.Person.Person AS p
INNER JOIN AdventureWorks2016.HumanResources.Employee e
ON p.BusinessEntityID = e.BusinessEntityID
INNER JOIN
(SELECT bea.BusinessEntityID, a.City
FROM AdventureWorks2016.Person.Address AS a
INNER JOIN AdventureWorks2016.Person.BusinessEntityAddress AS bea
ON a.AddressID = bea.AddressID) AS d
ON p.BusinessEntityID = d.BusinessEntityID
ORDER BY p.LastName, p.FirstName;
SQL: Reuse
Official Microsoft example of tSQL
15
SELECT RTRIM(p.FirstName) || ' ' || LTRIM(p.LastName) AS Name, d.City
FROM AdventureWorks2016.Person.Person AS p
INNER JOIN AdventureWorks2016.HumanResources.Employee e
ON p.BusinessEntityID = e.BusinessEntityID
INNER JOIN
(SELECT bea.BusinessEntityID, a.City
FROM AdventureWorks2016.Person.Address AS a
INNER JOIN AdventureWorks2016.Person.BusinessEntityAddress AS bea
ON a.AddressID = bea.AddressID) AS d
ON p.BusinessEntityID = d.BusinessEntityID
ORDER BY p.LastName, p.FirstName;
SQL: Reuse
N1QL (SQL++) version of the same query (after converting data into Couchbase)
16
public async Task<IActionResult> UpdatePurchaseOrderAsync(PersonUpdateApi personUpdateApi)
{
var transaction = await _context.Database.BeginTransactionAsync();
try
{
// update one or more rows of data, save changes
await _context.SaveChangesAsync();
// commit transaction
await transaction.CommitAsync();
return Ok($"Person {personUpdateApi.PersonId} name and email updated.");
}
catch (Exception ex)
{
// rollback transaction
await transaction.RollbackAsync();
return BadRequest("Something went wrong, transaction rolled back");
}
}
ACID Transactions: relational
C# example – SQL Server
17
public async Task<IActionResult> UpdatePurchaseOrderAsync(PersonUpdateApi personUpdateApi)
{
// create transaction
var transaction = Transactions.Create(cluster,
TransactionConfigBuilder.Create().DurabilityLevel(DurabilityLevel.None).Build());
try
{
await transaction.RunAsync(async (context) =>
{
// update one or more documents, save changes
// commit (implied)
});
return Ok($"Person {personUpdateApi.PersonId} name and email updated.");
}
catch (Exception ex)
{
// rollback (implied)
return BadRequest("Something went wrong, transaction rolled back.");
}
}
ACID Transactions: Couchbase
C# Example – Couchbase Server
18
Demo: Shifting App
19
3 Optimize
20
Consolidate
• Relational-style data is spread out
• Requires JOINs and/or ACID transactions (overhead)
• De-normalize
21
{
"PersonID": 123,
"FirstName": "Ken",
"MiddleName": "J",
"LastName": "Sánchez",
"ModifiedDate": "2009-01-07T00:00:00",
"EmailAddresses": [
{
"PersonID": 123,
"EmailAddress": "ken0@adventureworks.com",
"ModifiedDate": "2009-01-18T04:23:07"
}
]
}
{
"PersonID": 123,
"FirstName": "Ken",
"MiddleName": "J",
"LastName": "Sánchez",
"ModifiedDate": "2009-01-07T00:00:00"
}
{
"PersonID": 123,
"EmailAddress": "ken0@adventureworks.com",
"ModifiedDate": "2009-01-18T04:23:07"
}
Many-to-One consolidation
Person has 1 or more EmailAddress
23
var person = await coll.GetAsync("123");
SELECT p.*
FROM AdventureWorks2016.Person.Person p
WHERE p.PersonID = 123
Use the key-value API when possible
The key-value API is always faster
24
Demo: Refactoring
25
Next Steps
• Couchbase Playground: 30 min session
• https://couchbase.live/
• Examples and learning path
• Connect to the Capella trial
• Couchbase Capella Trial: 30 days
• https://cloud.couchbase.com/sign-up
• Self service tutorial
• Sample data / import data
• Post trial options
• Sign up with pay-as-you-go model
• Starter Kits: Discounted credits & professional services
26
Web
Twitter
Facebook
couchbase.com
twitter.com/couchbase
facebook.com/couchbase
CONTACT
Matthew Groves
https://github.com/mgroves/SqlServerToCouchbase
THANK YOU

More Related Content

What's hot (20)

PDF
Extracting Value from IOT using Azure Cosmos DB, Azure Synapse Analytics and ...
HostedbyConfluent
 
PDF
Big Data - in the cloud or rather on-premises?
Guido Schmutz
 
PPTX
MongoDB and Azure Databricks
MongoDB
 
PDF
Introducing the Hub for Data Orchestration
Alluxio, Inc.
 
PDF
Building a Microservices-based ERP System
MongoDB
 
PDF
MongoDB SoCal 2020: MongoDB Atlas Jump Start
MongoDB
 
PPTX
Maximizing MongoDB Performance on AWS
MongoDB
 
PDF
MongoDB World 2019: Ticketek: Scaling to Global Ticket Sales with MongoDB Atlas
MongoDB
 
PPTX
Curriculum Associates Strata NYC 2017
Kristi Lewandowski
 
PDF
Redis + Kafka = Performance at Scale | Julien Ruaux, Redis Labs
HostedbyConfluent
 
PPTX
Configuration in azure done right
Rick van den Bosch
 
PPTX
Vitalii Bondarenko "Machine Learning on Fast Data"
DataConf
 
PPTX
Google Cloud and Data Pipeline Patterns
Lynn Langit
 
PDF
MongoDB .local San Francisco 2020: MongoDB Atlas Jumpstart
MongoDB
 
PDF
Overcoming Today's Data Challenges with MongoDB
MongoDB
 
PDF
Webinar | How Clear Capital Delivers Always-on Appraisals on 122 Million Prop...
DataStax
 
PPTX
DocumentDB - NoSQL on Cloud at Reboot2015
Vidyasagar Machupalli
 
PPTX
Scaling Galaxy on Google Cloud Platform
Lynn Langit
 
PPTX
An afternoon with mongo db new delhi
Rajnish Verma
 
PPTX
NoSQL for the SQL Server Pro
Lynn Langit
 
Extracting Value from IOT using Azure Cosmos DB, Azure Synapse Analytics and ...
HostedbyConfluent
 
Big Data - in the cloud or rather on-premises?
Guido Schmutz
 
MongoDB and Azure Databricks
MongoDB
 
Introducing the Hub for Data Orchestration
Alluxio, Inc.
 
Building a Microservices-based ERP System
MongoDB
 
MongoDB SoCal 2020: MongoDB Atlas Jump Start
MongoDB
 
Maximizing MongoDB Performance on AWS
MongoDB
 
MongoDB World 2019: Ticketek: Scaling to Global Ticket Sales with MongoDB Atlas
MongoDB
 
Curriculum Associates Strata NYC 2017
Kristi Lewandowski
 
Redis + Kafka = Performance at Scale | Julien Ruaux, Redis Labs
HostedbyConfluent
 
Configuration in azure done right
Rick van den Bosch
 
Vitalii Bondarenko "Machine Learning on Fast Data"
DataConf
 
Google Cloud and Data Pipeline Patterns
Lynn Langit
 
MongoDB .local San Francisco 2020: MongoDB Atlas Jumpstart
MongoDB
 
Overcoming Today's Data Challenges with MongoDB
MongoDB
 
Webinar | How Clear Capital Delivers Always-on Appraisals on 122 Million Prop...
DataStax
 
DocumentDB - NoSQL on Cloud at Reboot2015
Vidyasagar Machupalli
 
Scaling Galaxy on Google Cloud Platform
Lynn Langit
 
An afternoon with mongo db new delhi
Rajnish Verma
 
NoSQL for the SQL Server Pro
Lynn Langit
 

Similar to Data Modeling and Relational to NoSQL (20)

KEY
OSCON 2011 CouchApps
Bradley Holt
 
PDF
Solutions for bi-directional integration between Oracle RDBMS and Apache Kafk...
confluent
 
PDF
Solutions for bi-directional Integration between Oracle RDMBS & Apache Kafka
Guido Schmutz
 
PDF
Solutions for bi-directional integration between Oracle RDBMS & Apache Kafka
Guido Schmutz
 
PPTX
CData Data Today: A Developer's Dilemma
Jerod Johnson
 
PDF
Siddhi - cloud-native stream processor
Sriskandarajah Suhothayan
 
PDF
MeteorJS Introduction
Nitya Narasimhan
 
PDF
Rethinking Syncing at AltConf 2019
Joe Keeley
 
PDF
NoSQL meets Microservices - Michael Hackstein
distributed matters
 
PPTX
StrongLoop Overview
Shubhra Kar
 
PPTX
비동기 회고 발표자료
Benjamin Kim
 
PPTX
Full Stack Development With Node.Js And NoSQL (Nic Raboy & Arun Gupta)
Red Hat Developers
 
KEY
Couchdb: No SQL? No driver? No problem
delagoya
 
PDF
jclouds High Level Overview by Adrian Cole
Everett Toews
 
PPTX
Soaring through the Clouds - Oracle Fusion Middleware Partner Forum 2016
Lucas Jellema
 
PPT
Windows Azure and a little SQL Data Services
ukdpe
 
PPTX
Integrate MongoDB & SQL data with a single REST API
Espresso Logic
 
ZIP
Javascript Everywhere From Nose To Tail
Cliffano Subagio
 
PDF
Couchbase@live person meetup july 22nd
Ido Shilon
 
PDF
Getting started with node JS
Hamdi Hmidi
 
OSCON 2011 CouchApps
Bradley Holt
 
Solutions for bi-directional integration between Oracle RDBMS and Apache Kafk...
confluent
 
Solutions for bi-directional Integration between Oracle RDMBS & Apache Kafka
Guido Schmutz
 
Solutions for bi-directional integration between Oracle RDBMS & Apache Kafka
Guido Schmutz
 
CData Data Today: A Developer's Dilemma
Jerod Johnson
 
Siddhi - cloud-native stream processor
Sriskandarajah Suhothayan
 
MeteorJS Introduction
Nitya Narasimhan
 
Rethinking Syncing at AltConf 2019
Joe Keeley
 
NoSQL meets Microservices - Michael Hackstein
distributed matters
 
StrongLoop Overview
Shubhra Kar
 
비동기 회고 발표자료
Benjamin Kim
 
Full Stack Development With Node.Js And NoSQL (Nic Raboy & Arun Gupta)
Red Hat Developers
 
Couchdb: No SQL? No driver? No problem
delagoya
 
jclouds High Level Overview by Adrian Cole
Everett Toews
 
Soaring through the Clouds - Oracle Fusion Middleware Partner Forum 2016
Lucas Jellema
 
Windows Azure and a little SQL Data Services
ukdpe
 
Integrate MongoDB & SQL data with a single REST API
Espresso Logic
 
Javascript Everywhere From Nose To Tail
Cliffano Subagio
 
Couchbase@live person meetup july 22nd
Ido Shilon
 
Getting started with node JS
Hamdi Hmidi
 
Ad

More from DATAVERSITY (20)

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

Recently uploaded (20)

PDF
The European Business Wallet: Why It Matters and How It Powers the EUDI Ecosy...
Lal Chandran
 
PPT
tuberculosiship-2106031cyyfuftufufufivifviviv
AkshaiRam
 
PDF
Data Chunking Strategies for RAG in 2025.pdf
Tamanna
 
PPTX
Module-5-Measures-of-Central-Tendency-Grouped-Data-1.pptx
lacsonjhoma0407
 
PPTX
apidays Singapore 2025 - The Quest for the Greenest LLM , Jean Philippe Ehre...
apidays
 
PDF
apidays Helsinki & North 2025 - APIs in the healthcare sector: hospitals inte...
apidays
 
PPTX
apidays Helsinki & North 2025 - API access control strategies beyond JWT bear...
apidays
 
PPT
AI Future trends and opportunities_oct7v1.ppt
SHIKHAKMEHTA
 
PPTX
AI Presentation Tool Pitch Deck Presentation.pptx
ShyamPanthavoor1
 
PDF
Development and validation of the Japanese version of the Organizational Matt...
Yoga Tokuyoshi
 
PPTX
apidays Helsinki & North 2025 - APIs at Scale: Designing for Alignment, Trust...
apidays
 
PPTX
b6057ea5-8e8c-4415-90c0-ed8e9666ffcd.pptx
Anees487379
 
PDF
Copia de Strategic Roadmap Infographics by Slidesgo.pptx (1).pdf
ssuserd4c6911
 
PPTX
apidays Helsinki & North 2025 - From Chaos to Clarity: Designing (AI-Ready) A...
apidays
 
PDF
apidays Helsinki & North 2025 - REST in Peace? Hunting the Dominant Design fo...
apidays
 
PPTX
apidays Singapore 2025 - From Data to Insights: Building AI-Powered Data APIs...
apidays
 
PPTX
apidays Munich 2025 - Building Telco-Aware Apps with Open Gateway APIs, Subhr...
apidays
 
PDF
Driving Employee Engagement in a Hybrid World.pdf
Mia scott
 
PDF
Web Scraping with Google Gemini 2.0 .pdf
Tamanna
 
PPTX
SlideEgg_501298-Agentic AI.pptx agentic ai
530BYManoj
 
The European Business Wallet: Why It Matters and How It Powers the EUDI Ecosy...
Lal Chandran
 
tuberculosiship-2106031cyyfuftufufufivifviviv
AkshaiRam
 
Data Chunking Strategies for RAG in 2025.pdf
Tamanna
 
Module-5-Measures-of-Central-Tendency-Grouped-Data-1.pptx
lacsonjhoma0407
 
apidays Singapore 2025 - The Quest for the Greenest LLM , Jean Philippe Ehre...
apidays
 
apidays Helsinki & North 2025 - APIs in the healthcare sector: hospitals inte...
apidays
 
apidays Helsinki & North 2025 - API access control strategies beyond JWT bear...
apidays
 
AI Future trends and opportunities_oct7v1.ppt
SHIKHAKMEHTA
 
AI Presentation Tool Pitch Deck Presentation.pptx
ShyamPanthavoor1
 
Development and validation of the Japanese version of the Organizational Matt...
Yoga Tokuyoshi
 
apidays Helsinki & North 2025 - APIs at Scale: Designing for Alignment, Trust...
apidays
 
b6057ea5-8e8c-4415-90c0-ed8e9666ffcd.pptx
Anees487379
 
Copia de Strategic Roadmap Infographics by Slidesgo.pptx (1).pdf
ssuserd4c6911
 
apidays Helsinki & North 2025 - From Chaos to Clarity: Designing (AI-Ready) A...
apidays
 
apidays Helsinki & North 2025 - REST in Peace? Hunting the Dominant Design fo...
apidays
 
apidays Singapore 2025 - From Data to Insights: Building AI-Powered Data APIs...
apidays
 
apidays Munich 2025 - Building Telco-Aware Apps with Open Gateway APIs, Subhr...
apidays
 
Driving Employee Engagement in a Hybrid World.pdf
Mia scott
 
Web Scraping with Google Gemini 2.0 .pdf
Tamanna
 
SlideEgg_501298-Agentic AI.pptx agentic ai
530BYManoj
 

Data Modeling and Relational to NoSQL

  • 1. Presented by Matthew D. Groves Data Modeling and Relational to NoSQL
  • 2. 2 Couchbase: The Modern NoSQL Database Sub-millisecond performance Simplicity & Scalability UC: Caching, Cart, IOT, User Profiles & Sessions Compare with: Redis, Elasticache, Aerospike Flexible JSON schema easily maps to RDBMS N1QL is SQL for JSON UC: Content Management, Catalog, Metadata, Customer 360 Compare with: DynamoDB, MongoDB, CosmosDB No ETL, SQL++, MPP Workload Isolation UC: Real-time Insights, Fraud detection, AI, Recommendation engines Compare with: MemSQL, CockroachDB, Hana Full-text Search Inverted Index UC: Log analysis, Collaboration, Website Search Compare with: Elasticsearch, Solr, Lucene Cloud to Edge Sync Peer to Peer Sync UC: Field Apps, Airplanes, Ships, Retail Stores, Restaurants, IOT Apps Compare with: Realm, SQLite, Berkeley DB Key-Value Store Document Database Analytics HTAP/HOAP Search Engine Edge Database
  • 3. 3 Are These Your Goals? • Identify a use case that can benefit from a modern database • Get some/all of data on to a modern database • Switch your application / Build a new application • Optimize your data model / access
  • 4. 01/ 02/ 03/ Mapping from relational Shift Application Code Optimize Agenda
  • 5. 5 1 Mapping from relational
  • 6. 6 Why now? • Couchbase 7.0 / Couchbase Capella • Scopes / collections • ACID Transactions • N1QL (SQL++)
  • 7. 7 So, is Couchbase a relational database now? • Distributed • Highly available • Flexible • Memory-first
  • 8. 8 SQL-to-Couchbase Dictionary Legacy (relational) Modern (Couchbase) Notes Server Cluster ➕ Scalability / High Availability Database Bucket ➕ Replication / Caching Schema Scope "dbo" and "_default" Table Collection ➕ Flexibility Row Document ➕ JSON tSQL (SQL) N1QL (SQL++) Full SQL implementation with: SELECT, JOIN, COMMIT, ROLLBACK, GROUP BY, INSERT, etc… Primary Key Document Key Index Index
  • 10. 10 Other Options/Tools • GlueSync - https://gluesync.com/ • Built by partner MOLO17 • Real-time sync between Couchbase and SQL Server / Oracle • Couchgres - https://github.com/metonymic-smokey/couchgres • Open source community project • Migrate from Postgres to Couchbase • Python script - https://bit.ly/mysqlPython • Bare-bones, script-based approach • Import CSV via UI
  • 13. 13 What do I need to shift? • SDK – connecting to the database • SQL – querying the database • ACID Transactions – updating data reliably
  • 14. 14 SELECT RTRIM(p.FirstName) + ' ' + LTRIM(p.LastName) AS Name, d.City FROM AdventureWorks2016.Person.Person AS p INNER JOIN AdventureWorks2016.HumanResources.Employee e ON p.BusinessEntityID = e.BusinessEntityID INNER JOIN (SELECT bea.BusinessEntityID, a.City FROM AdventureWorks2016.Person.Address AS a INNER JOIN AdventureWorks2016.Person.BusinessEntityAddress AS bea ON a.AddressID = bea.AddressID) AS d ON p.BusinessEntityID = d.BusinessEntityID ORDER BY p.LastName, p.FirstName; SQL: Reuse Official Microsoft example of tSQL
  • 15. 15 SELECT RTRIM(p.FirstName) || ' ' || LTRIM(p.LastName) AS Name, d.City FROM AdventureWorks2016.Person.Person AS p INNER JOIN AdventureWorks2016.HumanResources.Employee e ON p.BusinessEntityID = e.BusinessEntityID INNER JOIN (SELECT bea.BusinessEntityID, a.City FROM AdventureWorks2016.Person.Address AS a INNER JOIN AdventureWorks2016.Person.BusinessEntityAddress AS bea ON a.AddressID = bea.AddressID) AS d ON p.BusinessEntityID = d.BusinessEntityID ORDER BY p.LastName, p.FirstName; SQL: Reuse N1QL (SQL++) version of the same query (after converting data into Couchbase)
  • 16. 16 public async Task<IActionResult> UpdatePurchaseOrderAsync(PersonUpdateApi personUpdateApi) { var transaction = await _context.Database.BeginTransactionAsync(); try { // update one or more rows of data, save changes await _context.SaveChangesAsync(); // commit transaction await transaction.CommitAsync(); return Ok($"Person {personUpdateApi.PersonId} name and email updated."); } catch (Exception ex) { // rollback transaction await transaction.RollbackAsync(); return BadRequest("Something went wrong, transaction rolled back"); } } ACID Transactions: relational C# example – SQL Server
  • 17. 17 public async Task<IActionResult> UpdatePurchaseOrderAsync(PersonUpdateApi personUpdateApi) { // create transaction var transaction = Transactions.Create(cluster, TransactionConfigBuilder.Create().DurabilityLevel(DurabilityLevel.None).Build()); try { await transaction.RunAsync(async (context) => { // update one or more documents, save changes // commit (implied) }); return Ok($"Person {personUpdateApi.PersonId} name and email updated."); } catch (Exception ex) { // rollback (implied) return BadRequest("Something went wrong, transaction rolled back."); } } ACID Transactions: Couchbase C# Example – Couchbase Server
  • 20. 20 Consolidate • Relational-style data is spread out • Requires JOINs and/or ACID transactions (overhead) • De-normalize
  • 21. 21 { "PersonID": 123, "FirstName": "Ken", "MiddleName": "J", "LastName": "Sánchez", "ModifiedDate": "2009-01-07T00:00:00", "EmailAddresses": [ { "PersonID": 123, "EmailAddress": "[email protected]", "ModifiedDate": "2009-01-18T04:23:07" } ] } { "PersonID": 123, "FirstName": "Ken", "MiddleName": "J", "LastName": "Sánchez", "ModifiedDate": "2009-01-07T00:00:00" } { "PersonID": 123, "EmailAddress": "[email protected]", "ModifiedDate": "2009-01-18T04:23:07" } Many-to-One consolidation Person has 1 or more EmailAddress
  • 22. 23 var person = await coll.GetAsync("123"); SELECT p.* FROM AdventureWorks2016.Person.Person p WHERE p.PersonID = 123 Use the key-value API when possible The key-value API is always faster
  • 24. 25 Next Steps • Couchbase Playground: 30 min session • https://couchbase.live/ • Examples and learning path • Connect to the Capella trial • Couchbase Capella Trial: 30 days • https://cloud.couchbase.com/sign-up • Self service tutorial • Sample data / import data • Post trial options • Sign up with pay-as-you-go model • Starter Kits: Discounted credits & professional services