GithubHelp home page GithubHelp logo

cassandra-demo's Introduction

HOMEWORK

+----+------+---------+-------------+--------+--------+------------+-------------+
| id | Name | borough | BuildingNum | Street | ZipCode |   Phone    | CuisineType |
+----+------+---------+-------------+--------+--------+------------+-------------+
|    |      |         |             |        |        |            |             |
|    |      |         |             |        |        |            |             |
|    |      |         |             |        |        |            |             |
|    |      |         |             |        |        |            |             |
|    |      |         |             |        |        |            |             |
+----+------+---------+-------------+--------+--------+------------+-------------+

+---------------+----------------+-----------------------+------------------------+--------------+-------+-------+
| idRestaurant  | InspectionDate | ViolationCode         | ViolationDescription   | CriticalFlag | Score | GRADE |
+---------------+----------------+-----------------------+------------------------+--------------+-------+-------+
| PK            | PK             |                       |                        |              |       |       |
| (partition    | (clustering    |                       |                        |              |       |       |
| key)          | key)           |                       |                        |              |       |       |
+---------------+----------------+-----------------------+------------------------+--------------+-------+-------+

question 1: list all restaurants

SELECT * FROM Restaurant LIMIT 100;

question 2: list all restaurants names

SELECT Name FROM Restaurant LIMIT 100;

question 3: Name and borough of restaurant id 41569764.

SELECT Name, borough FROM Restaurant WHERE id = 41569764;

question 4: Dates and grades of inspections of restaurant id 41569764.

SELECT InspectionDate, GRADE FROM Inspection WHERE idRestaurant = 41569764;

question 5: Name all restaurants located in BROOKLYN.

In Cassandra, queries that filter on non-primary key columns are not allowed by default, as they can be very slow and inefficient. However, you can add the "ALLOW FILTERING" clause to your query to force Cassandra to execute the query, even if it involves filtering on a non-primary key column. Note that this can cause performance issues, especially if the table is large.

SELECT Name FROM Restaurant WHERE borough = 'BROOKLYN' ALLOW FILTERING;

question 6: Grades and scores for inspections on the restaurant with id 41569764 (score atleast 10)

SELECT GRADE, Score FROM Inspection WHERE idRestaurant = 41569764 AND Score >= 10 ALLOW FILTERING;

cassandra-demo's People

Contributors

wassef911 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.