SlideShare uma empresa Scribd logo
1 de 33
Three things you need to know about document
data modelling
Matthew Revell
Director of Developer Advocacy, Couchbase
1
We are still learning
2
©2014 Couchbase Inc.
Book learnin'
3
Our access pattern influences the data model
4
©2014 Couchbase Inc.
Ad-hoc versus predictable
5
Application layer computation Off-load computation
Predictable queries Key-value: pre-computed answers Views
Ad-hoc queries N1QL and key-value with manual
indexes
N1QL and views
Modelling for key-value
6
©2014 Couchbase Inc.
Principles for key-value modelling
7
Pre-compute answers asynchronously
Store object state
Choose when to embed data and when to refer to it
Design your keys well
Pre-computing answers
8
©2014 Couchbase Inc.
We're used to asking questions
9
©2014 Couchbase Inc.
A library of answers
10
©2014 Couchbase Inc.
Answer-oriented databases
11
http://martinfowler.com/bliki/AggregateOrientedDatabase.html
©2014 Couchbase Inc.
Save the answers for later use
12
Embed or refer?
13
©2014 Couchbase Inc.
An e-commerce order
14
©2014 Couchbase Inc.
The same order as a document
15
©2014 Couchbase Inc.
The same order as a document
16
©2014 Couchbase Inc.
When to embed data
17
You should embed data when:
Speed trumps all else
Slow moving data
No duplication
Application layer can keep multiple copies of same data in
sync
©2014 Couchbase Inc.
When to referdata
18
You should refer to data when:
Consistency is a priority
The data has large growth potential
Key design
19
©2014 Couchbase Inc.
Three ways to build a key
20
Key design is as important as document design.
There are three broad types of keys:
Human readable/deterministic: e.g., an email address
Computer generated/random: e.g., a UUID
Compound: e.g., a UUID with a deterministic portion
©2014 Couchbase Inc.
Human readable/deterministic key
21
public class user {
private String name;
private String email;
private String streetAddress;
private String city;
private String country;
private String postCode;
private String telephone;
private Array orders;
private Array productsViewed;
}
{
"name": "Matthew Revell",
"address": "11-21 Paul Street",
"city": "London",
"postCode": "EC2A 4JU",
"telephone": "44-20-3837-9130",
"orders": [ 1, 9, 698, 32 ],
“productsViewed”: [8, 33, 99, 100]
}
Key: matthew@couchbase.com
©2014 Couchbase Inc.
Counter key pattern
22
Application
user_id = incr(“counter_key")
add(user_id, data)
Creating a new user
add(email_address, user_id)
Application
key = get("matthew@couchbase.com")
get(key)
Finding a user by email address
©2014 Couchbase Inc.
Multiple look-up documents
23
u::count
1001
u::1001
{ "name": “Matthew Revell",
"facebook_id": 16172910,
"email": “matthew@couchbase.com”,
“password”: ab02d#Jf02K
"created_at": "5/1/2012 2:30am",
“facebook_access_token”: xox0v2dje20,
“twitter_access_token”: 20jffieieaaixixj }
fb::16172910
1001
nflx::2939202
1001
twtr::2920283830
1001
em::matthew@couchbase.com
1001
em::matthew@understated.co.uk
1001
uname::mrevell
1001
©2014 Couchbase Inc.
Compound keys
u::1001
{
"name": "Matthew Revell",
"email": "matthew@couchbase.com",
"address": "11-21 Paul Street",
"city": "London",
"postCode": "EC2A 4JU",
"telephone": "44-20-3837-9130",
"orders": [ 1, 9, 698, 32 ],
“productsViewed”: [8, 33, 99, 100]
}
©2014 Couchbase Inc.
Compound keys
u::1001
{
"name": "Matthew Revell",
"email": "matthew@couchbase.com",
"address": "11-21 Paul Street",
"city": "London",
"postCode": "EC2A 4JU",
"telephone": "44-20-3837-9130",
"orders": [ 1, 9, 698, 32 ]
}
u::1001::productsviewed
{
"productsList": [
8, 33, 99, 100
]
}
©2014 Couchbase Inc.
Compound keys
u::1001
{
"name": "Matthew Revell",
"email": "matthew@couchbase.com",
"address": "11-21 Paul Street",
"city": "London",
"postCode": "EC2A 4JU",
"telephone": "44-20-3837-9130",
"orders": [ 1, 9, 698, 32 ]
}
u::1001::productsviewed
{
"productsList": [
8, 33, 99, 100
]
}
p::8
{
id": 1,
"name": "T-shirt",
"description": "Red Couchbase shirt",
"quantityInStock": 99,
"image": "tshirt.jpg”
}
p::8::img
“http://someurl.com/tshirt.jpg”
Data modelling for N1QL
27
©2014 Couchbase Inc.
N1QL
28
• N1QL implements much of SQL++
• Dive into arrays and objects
• NEST data from JOINs
• UNNEST data
• Gracefully handles MISSING data
©2014 Couchbase Inc.
A N1QL Example
29
SELECT * FROM `travel-sample` r
JOIN `travel-sample` a
ON KEYS r.airlineid
WHERE r.sourceairport="LHR"
AND r.destinationairport = "SFO";
©2014 Couchbase Inc.
JOINs and keys
34
JOINs work on primary keys and secondary keys.
They JOIN across and within keyspaces (for now, that means buckets).
Airlines:
airline_24 ← Key (“primary key”)
{
"id": "24",
"type": "airline",
"name": "American Airlines",
"iata": "AA",
"icao": "AAL",
"callsign": "AMERICAN",
"country": "United States",
"active": "Y"
}
Routes:
route_5966 ← Key
{
"id": "5966",
"type": "route",
"airline": "AA",
"airlineid": "airline_24", ← This is the foreign key
"sourceairport": "MCO",
"destinationairport": "SEA",
"stops": "0",
"equipment": "737",
"schedule": [...
]
}
Next Steps
Couchbase Developer Portal
developer.couchbase.com
40
Forums
http://forums.couchbase.com
41

Mais conteúdo relacionado

Destaque

Covering letter vinod
Covering letter vinodCovering letter vinod
Covering letter vinod
vinod gupta
 

Destaque (7)

Segundo parcial tecnologias 2
Segundo parcial tecnologias 2Segundo parcial tecnologias 2
Segundo parcial tecnologias 2
 
Covering letter vinod
Covering letter vinodCovering letter vinod
Covering letter vinod
 
Académicos y universitarios ¡bienvenidos a nuestro mundo!
Académicos y universitarios ¡bienvenidos a nuestro mundo!Académicos y universitarios ¡bienvenidos a nuestro mundo!
Académicos y universitarios ¡bienvenidos a nuestro mundo!
 
Ieee 2016 Mobile Computing Papers Namakkal
Ieee 2016 Mobile Computing Papers NamakkalIeee 2016 Mobile Computing Papers Namakkal
Ieee 2016 Mobile Computing Papers Namakkal
 
ICH Q3 A (Impurities in New Drug Substances Q3A(R2) )
ICH Q3 A (Impurities in New Drug Substances Q3A(R2) )ICH Q3 A (Impurities in New Drug Substances Q3A(R2) )
ICH Q3 A (Impurities in New Drug Substances Q3A(R2) )
 
Tesis san marcos completo
Tesis san marcos completoTesis san marcos completo
Tesis san marcos completo
 
Q3D - Elemental Impurities: What implications for APIs & excipients suppliers?
Q3D - Elemental Impurities: What implications for APIs & excipients suppliers?Q3D - Elemental Impurities: What implications for APIs & excipients suppliers?
Q3D - Elemental Impurities: What implications for APIs & excipients suppliers?
 

Semelhante a Three things you need to know about document data modelling

Hadoop online training
Hadoop online trainingHadoop online training
Hadoop online training
Divya Shree
 

Semelhante a Three things you need to know about document data modelling (20)

NoSQL's biggest lie: SQL never went away - Martin Esmann
NoSQL's biggest lie: SQL never went away - Martin EsmannNoSQL's biggest lie: SQL never went away - Martin Esmann
NoSQL's biggest lie: SQL never went away - Martin Esmann
 
NoSQL’s biggest secret: NoSQL never went away
NoSQL’s biggest secret: NoSQL never went awayNoSQL’s biggest secret: NoSQL never went away
NoSQL’s biggest secret: NoSQL never went away
 
Big Data Day LA 2015 - Introducing N1QL: SQL for Documents by Jeff Morris of ...
Big Data Day LA 2015 - Introducing N1QL: SQL for Documents by Jeff Morris of ...Big Data Day LA 2015 - Introducing N1QL: SQL for Documents by Jeff Morris of ...
Big Data Day LA 2015 - Introducing N1QL: SQL for Documents by Jeff Morris of ...
 
Couchbase 101
Couchbase 101 Couchbase 101
Couchbase 101
 
The Why, When, and How of NoSQL - A Practical Approach
The Why, When, and How of NoSQL - A Practical ApproachThe Why, When, and How of NoSQL - A Practical Approach
The Why, When, and How of NoSQL - A Practical Approach
 
Json data modeling june 2017 - pittsburgh tech fest
Json data modeling   june 2017 - pittsburgh tech festJson data modeling   june 2017 - pittsburgh tech fest
Json data modeling june 2017 - pittsburgh tech fest
 
Exploring sql server 2016 bi
Exploring sql server 2016 biExploring sql server 2016 bi
Exploring sql server 2016 bi
 
Going native with Apache Cassandra
Going native with Apache CassandraGoing native with Apache Cassandra
Going native with Apache Cassandra
 
Neo4j Graph Summit 2024 Workshop - EMEA - Breda_and_Munchen.pdf
Neo4j Graph Summit 2024 Workshop - EMEA - Breda_and_Munchen.pdfNeo4j Graph Summit 2024 Workshop - EMEA - Breda_and_Munchen.pdf
Neo4j Graph Summit 2024 Workshop - EMEA - Breda_and_Munchen.pdf
 
Tutorial: Building Your First App with MongoDB Stitch
Tutorial: Building Your First App with MongoDB StitchTutorial: Building Your First App with MongoDB Stitch
Tutorial: Building Your First App with MongoDB Stitch
 
Slides: NoSQL Data Modeling Using JSON Documents – A Practical Approach
Slides: NoSQL Data Modeling Using JSON Documents – A Practical ApproachSlides: NoSQL Data Modeling Using JSON Documents – A Practical Approach
Slides: NoSQL Data Modeling Using JSON Documents – A Practical Approach
 
QCon 2014 - How Shutl delivers even faster with Neo4j
QCon 2014 - How Shutl delivers even faster with Neo4jQCon 2014 - How Shutl delivers even faster with Neo4j
QCon 2014 - How Shutl delivers even faster with Neo4j
 
No sq ls-biggest-lie_sql-never-went-away_martin-esmann
No sq ls-biggest-lie_sql-never-went-away_martin-esmannNo sq ls-biggest-lie_sql-never-went-away_martin-esmann
No sq ls-biggest-lie_sql-never-went-away_martin-esmann
 
An Introduction to the Microsoft Cloud
An Introduction to the Microsoft CloudAn Introduction to the Microsoft Cloud
An Introduction to the Microsoft Cloud
 
Hadoop online training
Hadoop online trainingHadoop online training
Hadoop online training
 
Building Your First App with MongoDB Stitch
Building Your First App with MongoDB StitchBuilding Your First App with MongoDB Stitch
Building Your First App with MongoDB Stitch
 
Access Apps for Office 365 with Power BI
Access Apps for Office 365 with Power BIAccess Apps for Office 365 with Power BI
Access Apps for Office 365 with Power BI
 
JSON Data Modeling in Document Database
JSON Data Modeling in Document DatabaseJSON Data Modeling in Document Database
JSON Data Modeling in Document Database
 
Hadoop Online Training in India
Hadoop Online Training in India Hadoop Online Training in India
Hadoop Online Training in India
 
Hadoop online training
Hadoop online trainingHadoop online training
Hadoop online training
 

Último

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Último (20)

EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 

Three things you need to know about document data modelling

  • 1. Three things you need to know about document data modelling Matthew Revell Director of Developer Advocacy, Couchbase 1
  • 2. We are still learning 2
  • 4. Our access pattern influences the data model 4
  • 5. ©2014 Couchbase Inc. Ad-hoc versus predictable 5 Application layer computation Off-load computation Predictable queries Key-value: pre-computed answers Views Ad-hoc queries N1QL and key-value with manual indexes N1QL and views
  • 7. ©2014 Couchbase Inc. Principles for key-value modelling 7 Pre-compute answers asynchronously Store object state Choose when to embed data and when to refer to it Design your keys well
  • 9. ©2014 Couchbase Inc. We're used to asking questions 9
  • 10. ©2014 Couchbase Inc. A library of answers 10
  • 11. ©2014 Couchbase Inc. Answer-oriented databases 11 http://martinfowler.com/bliki/AggregateOrientedDatabase.html
  • 12. ©2014 Couchbase Inc. Save the answers for later use 12
  • 14. ©2014 Couchbase Inc. An e-commerce order 14
  • 15. ©2014 Couchbase Inc. The same order as a document 15
  • 16. ©2014 Couchbase Inc. The same order as a document 16
  • 17. ©2014 Couchbase Inc. When to embed data 17 You should embed data when: Speed trumps all else Slow moving data No duplication Application layer can keep multiple copies of same data in sync
  • 18. ©2014 Couchbase Inc. When to referdata 18 You should refer to data when: Consistency is a priority The data has large growth potential
  • 20. ©2014 Couchbase Inc. Three ways to build a key 20 Key design is as important as document design. There are three broad types of keys: Human readable/deterministic: e.g., an email address Computer generated/random: e.g., a UUID Compound: e.g., a UUID with a deterministic portion
  • 21. ©2014 Couchbase Inc. Human readable/deterministic key 21 public class user { private String name; private String email; private String streetAddress; private String city; private String country; private String postCode; private String telephone; private Array orders; private Array productsViewed; } { "name": "Matthew Revell", "address": "11-21 Paul Street", "city": "London", "postCode": "EC2A 4JU", "telephone": "44-20-3837-9130", "orders": [ 1, 9, 698, 32 ], “productsViewed”: [8, 33, 99, 100] } Key: matthew@couchbase.com
  • 22. ©2014 Couchbase Inc. Counter key pattern 22 Application user_id = incr(“counter_key") add(user_id, data) Creating a new user add(email_address, user_id) Application key = get("matthew@couchbase.com") get(key) Finding a user by email address
  • 23. ©2014 Couchbase Inc. Multiple look-up documents 23 u::count 1001 u::1001 { "name": “Matthew Revell", "facebook_id": 16172910, "email": “matthew@couchbase.com”, “password”: ab02d#Jf02K "created_at": "5/1/2012 2:30am", “facebook_access_token”: xox0v2dje20, “twitter_access_token”: 20jffieieaaixixj } fb::16172910 1001 nflx::2939202 1001 twtr::2920283830 1001 em::matthew@couchbase.com 1001 em::matthew@understated.co.uk 1001 uname::mrevell 1001
  • 24. ©2014 Couchbase Inc. Compound keys u::1001 { "name": "Matthew Revell", "email": "matthew@couchbase.com", "address": "11-21 Paul Street", "city": "London", "postCode": "EC2A 4JU", "telephone": "44-20-3837-9130", "orders": [ 1, 9, 698, 32 ], “productsViewed”: [8, 33, 99, 100] }
  • 25. ©2014 Couchbase Inc. Compound keys u::1001 { "name": "Matthew Revell", "email": "matthew@couchbase.com", "address": "11-21 Paul Street", "city": "London", "postCode": "EC2A 4JU", "telephone": "44-20-3837-9130", "orders": [ 1, 9, 698, 32 ] } u::1001::productsviewed { "productsList": [ 8, 33, 99, 100 ] }
  • 26. ©2014 Couchbase Inc. Compound keys u::1001 { "name": "Matthew Revell", "email": "matthew@couchbase.com", "address": "11-21 Paul Street", "city": "London", "postCode": "EC2A 4JU", "telephone": "44-20-3837-9130", "orders": [ 1, 9, 698, 32 ] } u::1001::productsviewed { "productsList": [ 8, 33, 99, 100 ] } p::8 { id": 1, "name": "T-shirt", "description": "Red Couchbase shirt", "quantityInStock": 99, "image": "tshirt.jpg” } p::8::img “http://someurl.com/tshirt.jpg”
  • 28. ©2014 Couchbase Inc. N1QL 28 • N1QL implements much of SQL++ • Dive into arrays and objects • NEST data from JOINs • UNNEST data • Gracefully handles MISSING data
  • 29. ©2014 Couchbase Inc. A N1QL Example 29 SELECT * FROM `travel-sample` r JOIN `travel-sample` a ON KEYS r.airlineid WHERE r.sourceairport="LHR" AND r.destinationairport = "SFO";
  • 30. ©2014 Couchbase Inc. JOINs and keys 34 JOINs work on primary keys and secondary keys. They JOIN across and within keyspaces (for now, that means buckets). Airlines: airline_24 ← Key (“primary key”) { "id": "24", "type": "airline", "name": "American Airlines", "iata": "AA", "icao": "AAL", "callsign": "AMERICAN", "country": "United States", "active": "Y" } Routes: route_5966 ← Key { "id": "5966", "type": "route", "airline": "AA", "airlineid": "airline_24", ← This is the foreign key "sourceairport": "MCO", "destinationairport": "SEA", "stops": "0", "equipment": "737", "schedule": [... ] }

Notas do Editor

  1. Views let us automate that. View ain't going nowhere. Views might be the right way to index some stuff. Ultimately you're still doing KV but the indexes are slightly out of sync. Still, you're telling Couchbase how to go about giving you the data you want.
  2. Using the travel sample data we can find flights from LHR to SFO. Explain that we're aliasing travel-sample twice, because both sides of the join are in the same bucket. It's important not to conflate buckets and tables. Run this in cbq as it's too much for a GIF.
  3. Using the travel sample data we can find flights from LHR to SFO. Explain that we're aliasing travel-sample twice, because both sides of the join are in the same bucket. It's important not to conflate buckets and tables. Run this in cbq as it's too much for a GIF.
  4. Using the travel sample data we can find flights from LHR to SFO. Explain that we're aliasing travel-sample twice, because both sides of the join are in the same bucket. It's important not to conflate buckets and tables. Run this in cbq as it's too much for a GIF.
  5. Using the travel sample data we can find flights from LHR to SFO. Explain that we're aliasing travel-sample twice, because both sides of the join are in the same bucket. It's important not to conflate buckets and tables. Run this in cbq as it's too much for a GIF.
  6. Using the travel sample data we can find flights from LHR to SFO. Explain that we're aliasing travel-sample twice, because both sides of the join are in the same bucket. It's important not to conflate buckets and tables. Run this in cbq as it's too much for a GIF.
  7. Using the travel sample data we can find flights from LHR to SFO. Explain that we're aliasing travel-sample twice, because both sides of the join are in the same bucket. It's important not to conflate buckets and tables. Run this in cbq as it's too much for a GIF.
  8. It gives us airports, airlines, routes and that translates into flights.
  9. N1QL is all about giving you the data you want, not the data that happens to be in the database. JOINs are an essential part of that.
  10. Let's look at some sample docs from the travel sample.
  11. Here we use UNNEST and an inner join to find a list of all the flights from heathrow to SFO ordered by time. We are now aliasing the UNNESTed data too so we can easily use its data in our results.
  12. 31: Break