Question: Cassandra Query Language ( CQL ) Create and query tables. In this last step, you will create a couple of tables and add / delete
Cassandra Query Language CQL Create and query tables. In this last step, you will create a couple of tables and adddeletemodify data. Please see Datastax documentation for variabledata types in Cassandra.
Create a table ShopByCustomer with following columns: customer id customer name, location item name and item price. Customer name and location make the primary key. Please note that Cassandra does not have JOINS or FOREIGN KEYS, you focus on queries while designing. In this example, customer name is clustering key and location is the partition key. Here, you primarily query records by customer name. Insert at least six or seven records, like:
John Doe, Jacksonville, laptop, Bill Jones, Orlando, iPad, Sam Smith, Jacksonville, Monitor, Natalie Johnso, Orlando, Samsung S John Doe, Orlando, in TV Bill Jones, Jacksonville, Monitor,
Now query the above table ShopByCustomer to list all dataQuery the above table to show records by a given customer name, like John DoeQuery the table to display the output by item name Please note for efficiency it may need additional clause ALLOW FILTERING to display the output. If you really want to look up data by item name, you would have another table for that purpose with the same data.Query data for a customer eg John Doe and use order by location. Note, in a query a where clause with a column in the clustering key can be used so long as columns in the partition key are present in the where clause. Try the previous query and use order by item price.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
