SlideShare una empresa de Scribd logo
1 de 51
NoSQL revolution
   An introduction to the NoSQL world with real life
          examples using RavenDB and Redis




Matteo Baglini
http://it.linkedin.com/in/matteobaglini     www.dotnettoscana.org

Nicola Baldi
http://it.linkedin.com/in/nicolabaldi
Luigi Berrettini
http://it.linkedin.com/in/luigiberrettini                           15/12/2012
The   movement
Document databases in practice




Nicola Baldi
http://it.linkedin.com/in/nicolabaldi
Luigi Berrettini
http://it.linkedin.com/in/luigiberrettini
Overview



15/12/2012    Document databases in practice   4
Unbounded result sets problem

             Unbounded number of requests problem




15/12/2012              Document databases in practice - Overview   5
 They favor denormalization over
             composition and joins

       Relations are different than in RDBMSs

       They are schema-less, but attention should
             be paid in designing documents



15/12/2012              Document databases in practice - Overview   6
« a conceptual model should be drawn with
      little or no regard for the software that might
      implement it » (Martin Fowler, UML Distilled)



      A domain model should be independent from
      implementation details like persistence

             In RavenDB this is somewhat true

15/12/2012             Document databases in practice - Overview   7
 RDBMS are schema-full
       • tuples = sets of key-value pairs ⇒ flat structure
       • more complex data structures are stored as relations


   Document databases are schema-less
       • object graphs stored as docs ⇒ no flat structure
       • each document is treated as a single entity
             RavenDB suggested approach is to follow the
             aggregate pattern from the DDD book


15/12/2012                 Document databases in practice - Overview   8
ENTITY
     Some objects are not defined primarily by
       their attributes

     They represent a thread of identity that runs
       through time and often across distinct
       representations

     Mistaken identity can lead to data corruption


15/12/2012           Document databases in practice - Overview   9
VALUE OBJECT
 When you care only about the attributes of an
    element of the model, classify it as a value object
 Make it express the meaning of the attributes it
    conveys and give it related functionality
 Treat the value object as immutable

 Don't give it any identity and avoid the design
    complexities necessary to maintain entities

15/12/2012         Document databases in practice - Overview   10
AGGREGATE
     Invariants are consistency rules that must be
       maintained whenever data changes

     They’ll involve relationships within an aggregate
       (relations & foreign keys: order / orderlines)

     Invariants applied within an aggregate will be
       enforced with the completion of each transaction


15/12/2012            Document databases in practice - Overview   11
 Cluster entities and value objects into aggregates
    and define boundaries around each
 Choose one entity to be the root of each
    aggregate and control all access to the objects
    inside the boundary through the root
 Allow external objects to hold references to the
    root only
 Transient references to internal members can be
    passed out for use within a single operation only

15/12/2012         Document databases in practice - Overview   12
 Because the root controls access, it cannot
        be blindsided by changes to the internals


     This arrangement makes it practical to
        enforce all invariants for objects in the
        aggregate and for the aggregate as a
        whole in any state change



15/12/2012            Document databases in practice - Overview   13
Nested child document




15/12/2012      Document databases in practice - Overview   14
Document referenced by ID




15/12/2012      Document databases in practice - Overview   15
Denormalized reference
    we clone properties that we care about when
     displaying or processing a containing document
    avoids many cross document lookups and results in
     only the necessary data being transmitted over the
     network
    it makes other scenarios more difficult: if we add
     frequently changing data, keeping details in synch
     could become very demanding on the server
    use only for rarely changing data or for data that
     can be dereferenced by out-of-sync data

15/12/2012          Document databases in practice - Overview   16
15/12/2012   Document databases in practice - Overview   17
Order contains
 denormalized data
 from Customer
 and Product

 Full data are
 saved elsewhere



15/12/2012         Document databases in practice - Overview   18
15/12/2012   Document databases in practice - Overview   19
Querying




15/12/2012    Document databases in practice   20
 DocumentStore
             • used to connect to a RavenDB data store
             • thread-safe
             • one instance per database per application

       Session
             • used to perform operations on the database
             • not thread-safe
             • implements the Unit of Work pattern
               in a single session, a single document (identified
                by its key) always resolves to the same instance
               change tracking

15/12/2012                  Document databases in practice – Querying   21
15/12/2012   Document databases in practice – Querying   22
 Sequential GUID key
   • when document key is not relevant (e.g. log entries)
   • entity Id = sequential GUID (sorts well for indexing)
   • Id property missing / not set ⇒ server generates a key

 Identity key
   • entity Id = prefix + next available integer Id for it
   • Id property set to a prefix = value ending with slash
   • new DocumentStore ⇒ server sends a range of HiLo keys

 Assign a key yourself
   • for documents which already have native id (e.g. users)
15/12/2012           Document databases in practice – Querying   23
15/12/2012   Document databases in practice – Querying   24
 soft-limit = 128
       no Take() replaced by Take(128)
     hard-limit = 1024
       if x > 1024 Take(x) returns 1024 documents
15/12/2012          Document databases in practice – Querying   25
 RavenDB can skip over some results internally
       ⇒ TotalResults value invalidated

     For proper paging use SkippedResults:
      Skip(currentPage * pageSize + SkippedResults)

     Assuming a page size of 10…



15/12/2012          Document databases in practice – Querying   26
15/12/2012   Document databases in practice – Querying   27
15/12/2012   Document databases in practice – Querying   28
 RavenDB supports Count and Distinct

  SelectMany, GroupBy and Join are not supported

  The let keyword is not supported

  For such operations an index is needed



15/12/2012       Document databases in practice – Querying   29
All queries use an index to return results

    Dynamic = created automatically by the server

    Static = created explicitly by the user




15/12/2012         Document databases in practice – Querying   30
 no matching static index to query ⇒ RavenDB
      automatically creates a dynamic index on the
      fly (on first user query)

   based on requests coming in, RavenDB can
      decide to promote a temporary index to a
      permanent one



15/12/2012         Document databases in practice – Querying   31
 permanent

     expose much more functionality

     low latency: on first run dynamic indexes
       have performance issues

     map / reduce



15/12/2012           Document databases in practice – Querying   32
15/12/2012   Document databases in practice – Querying   33
15/12/2012   Document databases in practice – Querying   34
15/12/2012   Document databases in practice – Querying   35
Advanced topics




15/12/2012       Document databases in practice   36
 an index is made of documents

     document
        •    atomic unit of indexing and searching
        •    flat ⇒ recursion and joins must be denormalized
        •    flexible schema
        •    made of fields




15/12/2012              Document databases in practice – Advanced topics   37
 field
       • a name-value pair with associated info
       • can be indexed if you're going to search on it
         ⇒ tokenization by analysis
       • can be stored in order to preserve original
         untokenized value within document


   example of physical index structure
    {“__document_id”: “docs/1”, “tag”: “NoSQL”}



15/12/2012            Document databases in practice – Advanced topics   38
15/12/2012   Document databases in practice - Overview   39
15/12/2012   Document databases in practice – Advanced topics   40
15/12/2012   Document databases in practice – Advanced topics   41
One to one




15/12/2012     Document databases in practice – Advanced topics   42
One to many ⇒ SELECT N+1




15/12/2012   Document databases in practice – Advanced topics   43
Value type




15/12/2012     Document databases in practice – Advanced topics   44
 indexing: thread executed on creation or update
 server responds quickly BUT you may query stale
    indexes (better stale than offline)




15/12/2012        Document databases in practice – Advanced topics   45
15/12/2012   Document databases in practice – Advanced topics   46
documentStore.Conventions.DefaultQueryingConsistency

     ConsistencyOptions.QueryYourWrites
       same behavior of
       WaitForNonStaleResultsAsOfLastWrite

     ConsistencyOptions.MonotonicRead
       you never go back in time and read older
       data than what you have already seen


15/12/2012         Document databases in practice – Advanced topics   47
15/12/2012   Document databases in practice - Overview   48
15/12/2012   Document databases in practice - Overview   49
15/12/2012   Document databases in practice - Overview   50
Key-value databases in practice

Más contenido relacionado

La actualidad más candente

Introduction to Data Virtualization (session 1 from Packed Lunch Webinar Series)
Introduction to Data Virtualization (session 1 from Packed Lunch Webinar Series)Introduction to Data Virtualization (session 1 from Packed Lunch Webinar Series)
Introduction to Data Virtualization (session 1 from Packed Lunch Webinar Series)Denodo
 
Agile Data Warehousing: Using SDDM to Build a Virtualized ODS
Agile Data Warehousing: Using SDDM to Build a Virtualized ODSAgile Data Warehousing: Using SDDM to Build a Virtualized ODS
Agile Data Warehousing: Using SDDM to Build a Virtualized ODSKent Graziano
 
Data Modeling for NoSQL
Data Modeling for NoSQLData Modeling for NoSQL
Data Modeling for NoSQLTony Tam
 
Data Ninja Webinar Series: Realizing the Promise of Data Lakes
Data Ninja Webinar Series: Realizing the Promise of Data LakesData Ninja Webinar Series: Realizing the Promise of Data Lakes
Data Ninja Webinar Series: Realizing the Promise of Data LakesDenodo
 
Extreme BI: Creating Virtualized Hybrid Type 1+2 Dimensions
Extreme BI: Creating Virtualized Hybrid Type 1+2 DimensionsExtreme BI: Creating Virtualized Hybrid Type 1+2 Dimensions
Extreme BI: Creating Virtualized Hybrid Type 1+2 DimensionsKent Graziano
 
Red Hat JBoss Data Virtualization
Red Hat JBoss Data VirtualizationRed Hat JBoss Data Virtualization
Red Hat JBoss Data VirtualizationDLT Solutions
 
Building Data Warehouse in SQL Server
Building Data Warehouse in SQL ServerBuilding Data Warehouse in SQL Server
Building Data Warehouse in SQL ServerAntonios Chatzipavlis
 
Big Challenges in Data Modeling: NoSQL and Data Modeling
Big Challenges in Data Modeling: NoSQL and Data ModelingBig Challenges in Data Modeling: NoSQL and Data Modeling
Big Challenges in Data Modeling: NoSQL and Data ModelingDATAVERSITY
 
JBoss Enterprise Data Services (Data Virtualization)
JBoss Enterprise Data Services (Data Virtualization)JBoss Enterprise Data Services (Data Virtualization)
JBoss Enterprise Data Services (Data Virtualization)plarsen67
 
Numberate master presentation
Numberate master presentationNumberate master presentation
Numberate master presentationjkpeach
 
How to Achieve Fast Data Performance in Big Data, Logical Data Warehouse, and...
How to Achieve Fast Data Performance in Big Data, Logical Data Warehouse, and...How to Achieve Fast Data Performance in Big Data, Logical Data Warehouse, and...
How to Achieve Fast Data Performance in Big Data, Logical Data Warehouse, and...Denodo
 
SKILLWISE-SSIS DESIGN PATTERN FOR DATA WAREHOUSING
SKILLWISE-SSIS DESIGN PATTERN FOR DATA WAREHOUSINGSKILLWISE-SSIS DESIGN PATTERN FOR DATA WAREHOUSING
SKILLWISE-SSIS DESIGN PATTERN FOR DATA WAREHOUSINGSkillwise Group
 
Roland bouman modern_data_warehouse_architectures_data_vault_and_anchor_model...
Roland bouman modern_data_warehouse_architectures_data_vault_and_anchor_model...Roland bouman modern_data_warehouse_architectures_data_vault_and_anchor_model...
Roland bouman modern_data_warehouse_architectures_data_vault_and_anchor_model...Roland Bouman
 
Webinar: How MongoDB is Used to Manage Reference Data - May 2014
Webinar: How MongoDB is Used to Manage Reference Data - May 2014Webinar: How MongoDB is Used to Manage Reference Data - May 2014
Webinar: How MongoDB is Used to Manage Reference Data - May 2014MongoDB
 
Data Integration through Data Virtualization (SQL Server Konferenz 2019)
Data Integration through Data Virtualization (SQL Server Konferenz 2019)Data Integration through Data Virtualization (SQL Server Konferenz 2019)
Data Integration through Data Virtualization (SQL Server Konferenz 2019)Cathrine Wilhelmsen
 
owb-11gr2-new-features-summary-129693
owb-11gr2-new-features-summary-129693owb-11gr2-new-features-summary-129693
owb-11gr2-new-features-summary-129693Carnot Antonio Romero
 
Data stage scenario design 2 - job1
Data stage scenario   design 2 - job1Data stage scenario   design 2 - job1
Data stage scenario design 2 - job1Naresh Bala
 

La actualidad más candente (20)

Introduction to Data Virtualization (session 1 from Packed Lunch Webinar Series)
Introduction to Data Virtualization (session 1 from Packed Lunch Webinar Series)Introduction to Data Virtualization (session 1 from Packed Lunch Webinar Series)
Introduction to Data Virtualization (session 1 from Packed Lunch Webinar Series)
 
Agile Data Warehousing: Using SDDM to Build a Virtualized ODS
Agile Data Warehousing: Using SDDM to Build a Virtualized ODSAgile Data Warehousing: Using SDDM to Build a Virtualized ODS
Agile Data Warehousing: Using SDDM to Build a Virtualized ODS
 
Data Modeling for NoSQL
Data Modeling for NoSQLData Modeling for NoSQL
Data Modeling for NoSQL
 
Data Ninja Webinar Series: Realizing the Promise of Data Lakes
Data Ninja Webinar Series: Realizing the Promise of Data LakesData Ninja Webinar Series: Realizing the Promise of Data Lakes
Data Ninja Webinar Series: Realizing the Promise of Data Lakes
 
Extreme BI: Creating Virtualized Hybrid Type 1+2 Dimensions
Extreme BI: Creating Virtualized Hybrid Type 1+2 DimensionsExtreme BI: Creating Virtualized Hybrid Type 1+2 Dimensions
Extreme BI: Creating Virtualized Hybrid Type 1+2 Dimensions
 
Red Hat JBoss Data Virtualization
Red Hat JBoss Data VirtualizationRed Hat JBoss Data Virtualization
Red Hat JBoss Data Virtualization
 
Building Data Warehouse in SQL Server
Building Data Warehouse in SQL ServerBuilding Data Warehouse in SQL Server
Building Data Warehouse in SQL Server
 
Big Challenges in Data Modeling: NoSQL and Data Modeling
Big Challenges in Data Modeling: NoSQL and Data ModelingBig Challenges in Data Modeling: NoSQL and Data Modeling
Big Challenges in Data Modeling: NoSQL and Data Modeling
 
JBoss Enterprise Data Services (Data Virtualization)
JBoss Enterprise Data Services (Data Virtualization)JBoss Enterprise Data Services (Data Virtualization)
JBoss Enterprise Data Services (Data Virtualization)
 
Nosql data models
Nosql data modelsNosql data models
Nosql data models
 
Numberate master presentation
Numberate master presentationNumberate master presentation
Numberate master presentation
 
How to Achieve Fast Data Performance in Big Data, Logical Data Warehouse, and...
How to Achieve Fast Data Performance in Big Data, Logical Data Warehouse, and...How to Achieve Fast Data Performance in Big Data, Logical Data Warehouse, and...
How to Achieve Fast Data Performance in Big Data, Logical Data Warehouse, and...
 
SKILLWISE-SSIS DESIGN PATTERN FOR DATA WAREHOUSING
SKILLWISE-SSIS DESIGN PATTERN FOR DATA WAREHOUSINGSKILLWISE-SSIS DESIGN PATTERN FOR DATA WAREHOUSING
SKILLWISE-SSIS DESIGN PATTERN FOR DATA WAREHOUSING
 
Roland bouman modern_data_warehouse_architectures_data_vault_and_anchor_model...
Roland bouman modern_data_warehouse_architectures_data_vault_and_anchor_model...Roland bouman modern_data_warehouse_architectures_data_vault_and_anchor_model...
Roland bouman modern_data_warehouse_architectures_data_vault_and_anchor_model...
 
Webinar: How MongoDB is Used to Manage Reference Data - May 2014
Webinar: How MongoDB is Used to Manage Reference Data - May 2014Webinar: How MongoDB is Used to Manage Reference Data - May 2014
Webinar: How MongoDB is Used to Manage Reference Data - May 2014
 
Data Integration through Data Virtualization (SQL Server Konferenz 2019)
Data Integration through Data Virtualization (SQL Server Konferenz 2019)Data Integration through Data Virtualization (SQL Server Konferenz 2019)
Data Integration through Data Virtualization (SQL Server Konferenz 2019)
 
Nosql
NosqlNosql
Nosql
 
Nosql
NosqlNosql
Nosql
 
owb-11gr2-new-features-summary-129693
owb-11gr2-new-features-summary-129693owb-11gr2-new-features-summary-129693
owb-11gr2-new-features-summary-129693
 
Data stage scenario design 2 - job1
Data stage scenario   design 2 - job1Data stage scenario   design 2 - job1
Data stage scenario design 2 - job1
 

Similar a DotNetToscana: NoSQL Revolution - RavenDB

Database workshop - Encode | Bhuvan Gandhi | Vishwas Ganatra
Database workshop - Encode | Bhuvan Gandhi | Vishwas GanatraDatabase workshop - Encode | Bhuvan Gandhi | Vishwas Ganatra
Database workshop - Encode | Bhuvan Gandhi | Vishwas GanatraBhuvan Gandhi
 
Introduction to NoSQL and MongoDB
Introduction to NoSQL and MongoDBIntroduction to NoSQL and MongoDB
Introduction to NoSQL and MongoDBAhmed Farag
 
Denodo: Enabling a Data Mesh Architecture and Data Sharing Culture at Landsba...
Denodo: Enabling a Data Mesh Architecture and Data Sharing Culture at Landsba...Denodo: Enabling a Data Mesh Architecture and Data Sharing Culture at Landsba...
Denodo: Enabling a Data Mesh Architecture and Data Sharing Culture at Landsba...Denodo
 
Logical Data Fabric and Data Mesh – Driving Business Outcomes
Logical Data Fabric and Data Mesh – Driving Business OutcomesLogical Data Fabric and Data Mesh – Driving Business Outcomes
Logical Data Fabric and Data Mesh – Driving Business OutcomesDenodo
 
Prague data management meetup 2017-02-28
Prague data management meetup 2017-02-28Prague data management meetup 2017-02-28
Prague data management meetup 2017-02-28Martin Bém
 
3170722_BDA_GTU_Study_Material_Presentations_Unit-3_29092021094744AM.pdf
3170722_BDA_GTU_Study_Material_Presentations_Unit-3_29092021094744AM.pdf3170722_BDA_GTU_Study_Material_Presentations_Unit-3_29092021094744AM.pdf
3170722_BDA_GTU_Study_Material_Presentations_Unit-3_29092021094744AM.pdfKrishnaShah908060
 
Building next generation data warehouses
Building next generation data warehousesBuilding next generation data warehouses
Building next generation data warehousesAlex Meadows
 
SemTechBiz 2012 Panel on Linking Enterprise Data
SemTechBiz 2012 Panel on Linking Enterprise DataSemTechBiz 2012 Panel on Linking Enterprise Data
SemTechBiz 2012 Panel on Linking Enterprise Data3 Round Stones
 
Evolution of the DBA to Data Platform Administrator/Specialist
Evolution of the DBA to Data Platform Administrator/SpecialistEvolution of the DBA to Data Platform Administrator/Specialist
Evolution of the DBA to Data Platform Administrator/SpecialistTony Rogerson
 
SQL vs NoSQL Data Modeling.pptx
SQL vs NoSQL Data Modeling.pptxSQL vs NoSQL Data Modeling.pptx
SQL vs NoSQL Data Modeling.pptxGarimaHasija1
 
introduction to NOSQL Database
introduction to NOSQL Databaseintroduction to NOSQL Database
introduction to NOSQL Databasenehabsairam
 
Introduction to document db- Global Azure Bootcamp 2016
Introduction to document db- Global Azure Bootcamp 2016Introduction to document db- Global Azure Bootcamp 2016
Introduction to document db- Global Azure Bootcamp 2016Jalpesh Vadgama
 
Things learned from OpenWorld 2013
Things learned from OpenWorld 2013Things learned from OpenWorld 2013
Things learned from OpenWorld 2013Connor McDonald
 
Getting to Real-Time in a Multi-Model Architecture
Getting to Real-Time in a Multi-Model ArchitectureGetting to Real-Time in a Multi-Model Architecture
Getting to Real-Time in a Multi-Model ArchitectureBenjamin Nussbaum
 

Similar a DotNetToscana: NoSQL Revolution - RavenDB (20)

Database workshop - Encode | Bhuvan Gandhi | Vishwas Ganatra
Database workshop - Encode | Bhuvan Gandhi | Vishwas GanatraDatabase workshop - Encode | Bhuvan Gandhi | Vishwas Ganatra
Database workshop - Encode | Bhuvan Gandhi | Vishwas Ganatra
 
Introduction to NoSQL and MongoDB
Introduction to NoSQL and MongoDBIntroduction to NoSQL and MongoDB
Introduction to NoSQL and MongoDB
 
Denodo: Enabling a Data Mesh Architecture and Data Sharing Culture at Landsba...
Denodo: Enabling a Data Mesh Architecture and Data Sharing Culture at Landsba...Denodo: Enabling a Data Mesh Architecture and Data Sharing Culture at Landsba...
Denodo: Enabling a Data Mesh Architecture and Data Sharing Culture at Landsba...
 
Logical Data Fabric and Data Mesh – Driving Business Outcomes
Logical Data Fabric and Data Mesh – Driving Business OutcomesLogical Data Fabric and Data Mesh – Driving Business Outcomes
Logical Data Fabric and Data Mesh – Driving Business Outcomes
 
Prague data management meetup 2017-02-28
Prague data management meetup 2017-02-28Prague data management meetup 2017-02-28
Prague data management meetup 2017-02-28
 
3170722_BDA_GTU_Study_Material_Presentations_Unit-3_29092021094744AM.pdf
3170722_BDA_GTU_Study_Material_Presentations_Unit-3_29092021094744AM.pdf3170722_BDA_GTU_Study_Material_Presentations_Unit-3_29092021094744AM.pdf
3170722_BDA_GTU_Study_Material_Presentations_Unit-3_29092021094744AM.pdf
 
Chap14
Chap14Chap14
Chap14
 
Unit-10.pptx
Unit-10.pptxUnit-10.pptx
Unit-10.pptx
 
DBMS outline.pptx
DBMS outline.pptxDBMS outline.pptx
DBMS outline.pptx
 
Building next generation data warehouses
Building next generation data warehousesBuilding next generation data warehouses
Building next generation data warehouses
 
SemTechBiz 2012 Panel on Linking Enterprise Data
SemTechBiz 2012 Panel on Linking Enterprise DataSemTechBiz 2012 Panel on Linking Enterprise Data
SemTechBiz 2012 Panel on Linking Enterprise Data
 
No sql
No sqlNo sql
No sql
 
Evolution of the DBA to Data Platform Administrator/Specialist
Evolution of the DBA to Data Platform Administrator/SpecialistEvolution of the DBA to Data Platform Administrator/Specialist
Evolution of the DBA to Data Platform Administrator/Specialist
 
Sql good practices
Sql good practicesSql good practices
Sql good practices
 
SQL vs NoSQL Data Modeling.pptx
SQL vs NoSQL Data Modeling.pptxSQL vs NoSQL Data Modeling.pptx
SQL vs NoSQL Data Modeling.pptx
 
introduction to NOSQL Database
introduction to NOSQL Databaseintroduction to NOSQL Database
introduction to NOSQL Database
 
Introduction to document db- Global Azure Bootcamp 2016
Introduction to document db- Global Azure Bootcamp 2016Introduction to document db- Global Azure Bootcamp 2016
Introduction to document db- Global Azure Bootcamp 2016
 
Pass bac jd_sm
Pass bac jd_smPass bac jd_sm
Pass bac jd_sm
 
Things learned from OpenWorld 2013
Things learned from OpenWorld 2013Things learned from OpenWorld 2013
Things learned from OpenWorld 2013
 
Getting to Real-Time in a Multi-Model Architecture
Getting to Real-Time in a Multi-Model ArchitectureGetting to Real-Time in a Multi-Model Architecture
Getting to Real-Time in a Multi-Model Architecture
 

Último

TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 

Último (20)

TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 

DotNetToscana: NoSQL Revolution - RavenDB

  • 1. NoSQL revolution An introduction to the NoSQL world with real life examples using RavenDB and Redis Matteo Baglini http://it.linkedin.com/in/matteobaglini www.dotnettoscana.org Nicola Baldi http://it.linkedin.com/in/nicolabaldi Luigi Berrettini http://it.linkedin.com/in/luigiberrettini 15/12/2012
  • 2. The movement
  • 3. Document databases in practice Nicola Baldi http://it.linkedin.com/in/nicolabaldi Luigi Berrettini http://it.linkedin.com/in/luigiberrettini
  • 4. Overview 15/12/2012 Document databases in practice 4
  • 5. Unbounded result sets problem Unbounded number of requests problem 15/12/2012 Document databases in practice - Overview 5
  • 6.  They favor denormalization over composition and joins  Relations are different than in RDBMSs  They are schema-less, but attention should be paid in designing documents 15/12/2012 Document databases in practice - Overview 6
  • 7. « a conceptual model should be drawn with little or no regard for the software that might implement it » (Martin Fowler, UML Distilled) A domain model should be independent from implementation details like persistence In RavenDB this is somewhat true 15/12/2012 Document databases in practice - Overview 7
  • 8.  RDBMS are schema-full • tuples = sets of key-value pairs ⇒ flat structure • more complex data structures are stored as relations  Document databases are schema-less • object graphs stored as docs ⇒ no flat structure • each document is treated as a single entity RavenDB suggested approach is to follow the aggregate pattern from the DDD book 15/12/2012 Document databases in practice - Overview 8
  • 9. ENTITY  Some objects are not defined primarily by their attributes  They represent a thread of identity that runs through time and often across distinct representations  Mistaken identity can lead to data corruption 15/12/2012 Document databases in practice - Overview 9
  • 10. VALUE OBJECT  When you care only about the attributes of an element of the model, classify it as a value object  Make it express the meaning of the attributes it conveys and give it related functionality  Treat the value object as immutable  Don't give it any identity and avoid the design complexities necessary to maintain entities 15/12/2012 Document databases in practice - Overview 10
  • 11. AGGREGATE  Invariants are consistency rules that must be maintained whenever data changes  They’ll involve relationships within an aggregate (relations & foreign keys: order / orderlines)  Invariants applied within an aggregate will be enforced with the completion of each transaction 15/12/2012 Document databases in practice - Overview 11
  • 12.  Cluster entities and value objects into aggregates and define boundaries around each  Choose one entity to be the root of each aggregate and control all access to the objects inside the boundary through the root  Allow external objects to hold references to the root only  Transient references to internal members can be passed out for use within a single operation only 15/12/2012 Document databases in practice - Overview 12
  • 13.  Because the root controls access, it cannot be blindsided by changes to the internals  This arrangement makes it practical to enforce all invariants for objects in the aggregate and for the aggregate as a whole in any state change 15/12/2012 Document databases in practice - Overview 13
  • 14. Nested child document 15/12/2012 Document databases in practice - Overview 14
  • 15. Document referenced by ID 15/12/2012 Document databases in practice - Overview 15
  • 16. Denormalized reference  we clone properties that we care about when displaying or processing a containing document  avoids many cross document lookups and results in only the necessary data being transmitted over the network  it makes other scenarios more difficult: if we add frequently changing data, keeping details in synch could become very demanding on the server  use only for rarely changing data or for data that can be dereferenced by out-of-sync data 15/12/2012 Document databases in practice - Overview 16
  • 17. 15/12/2012 Document databases in practice - Overview 17
  • 18. Order contains denormalized data from Customer and Product Full data are saved elsewhere 15/12/2012 Document databases in practice - Overview 18
  • 19. 15/12/2012 Document databases in practice - Overview 19
  • 20. Querying 15/12/2012 Document databases in practice 20
  • 21.  DocumentStore • used to connect to a RavenDB data store • thread-safe • one instance per database per application  Session • used to perform operations on the database • not thread-safe • implements the Unit of Work pattern  in a single session, a single document (identified by its key) always resolves to the same instance  change tracking 15/12/2012 Document databases in practice – Querying 21
  • 22. 15/12/2012 Document databases in practice – Querying 22
  • 23.  Sequential GUID key • when document key is not relevant (e.g. log entries) • entity Id = sequential GUID (sorts well for indexing) • Id property missing / not set ⇒ server generates a key  Identity key • entity Id = prefix + next available integer Id for it • Id property set to a prefix = value ending with slash • new DocumentStore ⇒ server sends a range of HiLo keys  Assign a key yourself • for documents which already have native id (e.g. users) 15/12/2012 Document databases in practice – Querying 23
  • 24. 15/12/2012 Document databases in practice – Querying 24
  • 25.  soft-limit = 128 no Take() replaced by Take(128)  hard-limit = 1024 if x > 1024 Take(x) returns 1024 documents 15/12/2012 Document databases in practice – Querying 25
  • 26.  RavenDB can skip over some results internally ⇒ TotalResults value invalidated  For proper paging use SkippedResults: Skip(currentPage * pageSize + SkippedResults)  Assuming a page size of 10… 15/12/2012 Document databases in practice – Querying 26
  • 27. 15/12/2012 Document databases in practice – Querying 27
  • 28. 15/12/2012 Document databases in practice – Querying 28
  • 29.  RavenDB supports Count and Distinct  SelectMany, GroupBy and Join are not supported  The let keyword is not supported  For such operations an index is needed 15/12/2012 Document databases in practice – Querying 29
  • 30. All queries use an index to return results  Dynamic = created automatically by the server  Static = created explicitly by the user 15/12/2012 Document databases in practice – Querying 30
  • 31.  no matching static index to query ⇒ RavenDB automatically creates a dynamic index on the fly (on first user query)  based on requests coming in, RavenDB can decide to promote a temporary index to a permanent one 15/12/2012 Document databases in practice – Querying 31
  • 32.  permanent  expose much more functionality  low latency: on first run dynamic indexes have performance issues  map / reduce 15/12/2012 Document databases in practice – Querying 32
  • 33. 15/12/2012 Document databases in practice – Querying 33
  • 34. 15/12/2012 Document databases in practice – Querying 34
  • 35. 15/12/2012 Document databases in practice – Querying 35
  • 36. Advanced topics 15/12/2012 Document databases in practice 36
  • 37.  an index is made of documents  document • atomic unit of indexing and searching • flat ⇒ recursion and joins must be denormalized • flexible schema • made of fields 15/12/2012 Document databases in practice – Advanced topics 37
  • 38.  field • a name-value pair with associated info • can be indexed if you're going to search on it ⇒ tokenization by analysis • can be stored in order to preserve original untokenized value within document  example of physical index structure {“__document_id”: “docs/1”, “tag”: “NoSQL”} 15/12/2012 Document databases in practice – Advanced topics 38
  • 39. 15/12/2012 Document databases in practice - Overview 39
  • 40. 15/12/2012 Document databases in practice – Advanced topics 40
  • 41. 15/12/2012 Document databases in practice – Advanced topics 41
  • 42. One to one 15/12/2012 Document databases in practice – Advanced topics 42
  • 43. One to many ⇒ SELECT N+1 15/12/2012 Document databases in practice – Advanced topics 43
  • 44. Value type 15/12/2012 Document databases in practice – Advanced topics 44
  • 45.  indexing: thread executed on creation or update  server responds quickly BUT you may query stale indexes (better stale than offline) 15/12/2012 Document databases in practice – Advanced topics 45
  • 46. 15/12/2012 Document databases in practice – Advanced topics 46
  • 47. documentStore.Conventions.DefaultQueryingConsistency  ConsistencyOptions.QueryYourWrites same behavior of WaitForNonStaleResultsAsOfLastWrite  ConsistencyOptions.MonotonicRead you never go back in time and read older data than what you have already seen 15/12/2012 Document databases in practice – Advanced topics 47
  • 48. 15/12/2012 Document databases in practice - Overview 48
  • 49. 15/12/2012 Document databases in practice - Overview 49
  • 50. 15/12/2012 Document databases in practice - Overview 50

Notas del editor

  1. https://github.com/ravendb/ravendb/pull/408