+----+------+---------+-------------+--------+--------+------------+-------------+
| id | Name | borough | BuildingNum | Street | ZipCode | Phone | CuisineType |
+----+------+---------+-------------+--------+--------+------------+-------------+
| | | | | | | | |
| | | | | | | | |
| | | | | | | | |
| | | | | | | | |
| | | | | | | | |
+----+------+---------+-------------+--------+--------+------------+-------------+
+---------------+----------------+-----------------------+------------------------+--------------+-------+-------+
| idRestaurant | InspectionDate | ViolationCode | ViolationDescription | CriticalFlag | Score | GRADE |
+---------------+----------------+-----------------------+------------------------+--------------+-------+-------+
| PK | PK | | | | | |
| (partition | (clustering | | | | | |
| key) | key) | | | | | |
+---------------+----------------+-----------------------+------------------------+--------------+-------+-------+
SELECT * FROM Restaurant LIMIT 100;
SELECT Name FROM Restaurant LIMIT 100;
SELECT Name, borough FROM Restaurant WHERE id = 41569764;
SELECT InspectionDate, GRADE FROM Inspection WHERE idRestaurant = 41569764;
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;
SELECT GRADE, Score FROM Inspection WHERE idRestaurant = 41569764 AND Score >= 10 ALLOW FILTERING;