| |
| |
| <!DOCTYPE html> |
| <!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> |
| <!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> |
| <head> |
| <meta charset="utf-8"> |
| |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| |
| <title>Defining Application Queries — Apache Cassandra Documentation v4.0-rc2</title> |
| |
| |
| |
| |
| |
| |
| |
| |
| <script type="text/javascript" src="../_static/js/modernizr.min.js"></script> |
| |
| |
| <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script> |
| <script type="text/javascript" src="../_static/jquery.js"></script> |
| <script type="text/javascript" src="../_static/underscore.js"></script> |
| <script type="text/javascript" src="../_static/doctools.js"></script> |
| <script type="text/javascript" src="../_static/language_data.js"></script> |
| <script async="async" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-AMS-MML_HTMLorMML"></script> |
| |
| <script type="text/javascript" src="../_static/js/theme.js"></script> |
| |
| |
| |
| |
| <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" /> |
| <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> |
| <link rel="stylesheet" href="../_static/extra.css" type="text/css" /> |
| <link rel="index" title="Index" href="../genindex.html" /> |
| <link rel="search" title="Search" href="../search.html" /> |
| <link rel="next" title="Logical Data Modeling" href="data_modeling_logical.html" /> |
| <link rel="prev" title="RDBMS Design" href="data_modeling_rdbms.html" /> |
| </head> |
| |
| <body class="wy-body-for-nav"> |
| |
| |
| <div class="wy-grid-for-nav"> |
| |
| <nav data-toggle="wy-nav-shift" class="wy-nav-side"> |
| <div class="wy-side-scroll"> |
| <div class="wy-side-nav-search" > |
| |
| |
| |
| <a href="../index.html" class="icon icon-home"> Apache Cassandra |
| |
| |
| |
| </a> |
| |
| |
| |
| |
| <div class="version"> |
| 4.0-rc2 |
| </div> |
| |
| |
| |
| |
| <div role="search"> |
| <form id="rtd-search-form" class="wy-form" action="../search.html" method="get"> |
| <input type="text" name="q" placeholder="Search docs" /> |
| <input type="hidden" name="check_keywords" value="yes" /> |
| <input type="hidden" name="area" value="default" /> |
| </form> |
| </div> |
| |
| |
| </div> |
| |
| <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> |
| |
| |
| |
| |
| |
| |
| <ul class="current"> |
| <li class="toctree-l1"><a class="reference internal" href="../getting_started/index.html">Getting Started</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../new/index.html">New Features in Apache Cassandra 4.0</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../architecture/index.html">Architecture</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../cql/index.html">The Cassandra Query Language (CQL)</a></li> |
| <li class="toctree-l1 current"><a class="reference internal" href="index.html">Data Modeling</a><ul class="current"> |
| <li class="toctree-l2"><a class="reference internal" href="intro.html">Introduction</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="data_modeling_conceptual.html">Conceptual Data Modeling</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="data_modeling_rdbms.html">RDBMS Design</a></li> |
| <li class="toctree-l2 current"><a class="current reference internal" href="#">Defining Application Queries</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="data_modeling_logical.html">Logical Data Modeling</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="data_modeling_physical.html">Physical Data Modeling</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="data_modeling_refining.html">Evaluating and Refining Data Models</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="data_modeling_schema.html">Defining Database Schema</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="data_modeling_tools.html">Cassandra Data Modeling Tools</a></li> |
| </ul> |
| </li> |
| <li class="toctree-l1"><a class="reference internal" href="../configuration/index.html">Configuring Cassandra</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../operating/index.html">Operating Cassandra</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../tools/index.html">Cassandra Tools</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../troubleshooting/index.html">Troubleshooting</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../development/index.html">Contributing to Cassandra</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../faq/index.html">Frequently Asked Questions</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../plugins/index.html">Third-Party Plugins</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../bugs.html">Reporting Bugs</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../contactus.html">Contact us</a></li> |
| </ul> |
| |
| |
| |
| </div> |
| </div> |
| </nav> |
| |
| <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> |
| |
| |
| <nav class="wy-nav-top" aria-label="top navigation"> |
| |
| <i data-toggle="wy-nav-top" class="fa fa-bars"></i> |
| <a href="../index.html">Apache Cassandra</a> |
| |
| </nav> |
| |
| |
| <div class="wy-nav-content"> |
| |
| <div class="rst-content"> |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| <div role="navigation" aria-label="breadcrumbs navigation"> |
| |
| <ul class="wy-breadcrumbs"> |
| |
| <li><a href="../index.html">Docs</a> »</li> |
| |
| <li><a href="index.html">Data Modeling</a> »</li> |
| |
| <li>Defining Application Queries</li> |
| |
| |
| <li class="wy-breadcrumbs-aside"> |
| |
| |
| <a href="../_sources/data_modeling/data_modeling_queries.rst.txt" rel="nofollow"> View page source</a> |
| |
| |
| </li> |
| |
| </ul> |
| |
| |
| <hr/> |
| </div> |
| <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> |
| <div itemprop="articleBody"> |
| |
| <div class="section" id="defining-application-queries"> |
| <h1>Defining Application Queries<a class="headerlink" href="#defining-application-queries" title="Permalink to this headline">¶</a></h1> |
| <p>Let’s try the query-first approach to start designing the data model for |
| a hotel application. The user interface design for the application is |
| often a great artifact to use to begin identifying queries. Let’s assume |
| that you’ve talked with the project stakeholders and your UX designers |
| have produced user interface designs or wireframes for the key use |
| cases. You’ll likely have a list of shopping queries like the following:</p> |
| <ul class="simple"> |
| <li><p>Q1. Find hotels near a given point of interest.</p></li> |
| <li><p>Q2. Find information about a given hotel, such as its name and |
| location.</p></li> |
| <li><p>Q3. Find points of interest near a given hotel.</p></li> |
| <li><p>Q4. Find an available room in a given date range.</p></li> |
| <li><p>Q5. Find the rate and amenities for a room.</p></li> |
| </ul> |
| <p>It is often helpful to be able to refer |
| to queries by a shorthand number rather that explaining them in full. |
| The queries listed here are numbered Q1, Q2, and so on, which is how they |
| are referenced in diagrams throughout the example.</p> |
| <p>Now if the application is to be a success, you’ll certainly want |
| customers to be able to book reservations at hotels. This includes |
| steps such as selecting an available room and entering their guest |
| information. So clearly you will also need some queries that address the |
| reservation and guest entities from the conceptual data model. Even |
| here, however, you’ll want to think not only from the customer |
| perspective in terms of how the data is written, but also in terms of |
| how the data will be queried by downstream use cases.</p> |
| <p>You natural tendency as might be to focus first on |
| designing the tables to store reservation and guest records, and only |
| then start thinking about the queries that would access them. You may |
| have felt a similar tension already when discussing the |
| shopping queries before, thinking “but where did the hotel and point of |
| interest data come from?” Don’t worry, you will see soon enough. |
| Here are some queries that describe how users will access |
| reservations:</p> |
| <ul class="simple"> |
| <li><p>Q6. Lookup a reservation by confirmation number.</p></li> |
| <li><p>Q7. Lookup a reservation by hotel, date, and guest name.</p></li> |
| <li><p>Q8. Lookup all reservations by guest name.</p></li> |
| <li><p>Q9. View guest details.</p></li> |
| </ul> |
| <p>All of the queries are shown in the context of the workflow of the |
| application in the figure below. Each box on the diagram represents a |
| step in the application workflow, with arrows indicating the flows |
| between steps and the associated query. If you’ve modeled the application |
| well, each step of the workflow accomplishes a task that “unlocks” |
| subsequent steps. For example, the “View hotels near POI” task helps |
| the application learn about several hotels, including their unique keys. |
| The key for a selected hotel may be used as part of Q2, in order to |
| obtain detailed description of the hotel. The act of booking a room |
| creates a reservation record that may be accessed by the guest and |
| hotel staff at a later time through various additional queries.</p> |
| <img alt="../_images/data_modeling_hotel_queries.png" src="../_images/data_modeling_hotel_queries.png" /> |
| <p><em>Material adapted from Cassandra, The Definitive Guide. Published by |
| O’Reilly Media, Inc. Copyright © 2020 Jeff Carpenter, Eben Hewitt. |
| All rights reserved. Used with permission.</em></p> |
| </div> |
| |
| |
| </div> |
| |
| </div> |
| <footer> |
| |
| <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> |
| |
| <a href="data_modeling_logical.html" class="btn btn-neutral float-right" title="Logical Data Modeling" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a> |
| |
| |
| <a href="data_modeling_rdbms.html" class="btn btn-neutral float-left" title="RDBMS Design" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a> |
| |
| </div> |
| |
| |
| <hr/> |
| |
| <div role="contentinfo"> |
| <p> |
| © Copyright 2020, The Apache Cassandra team |
| |
| </p> |
| </div> |
| Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. |
| |
| </footer> |
| |
| </div> |
| </div> |
| |
| </section> |
| |
| </div> |
| |
| |
| |
| <script type="text/javascript"> |
| jQuery(function () { |
| SphinxRtdTheme.Navigation.enable(true); |
| }); |
| </script> |
| |
| |
| |
| |
| |
| |
| </body> |
| </html> |