Cassandra lookup table for vanity urls and Base64 encoded UUIDs

642 Views Asked by At

The scenario

A large, high performance, scalable, distributed site about cats.

The details

  • Each cat has it's own page containing some details such as average sleep hours, favourite food and worst enemies.
  • Pages can be accessed either via a vanity-url when set (ie. cats.com/terminator-cat) or a Base64Url representation of it's UUID (ie. cats.com/w4rTb789mmN0c...)
  • There is an API aswell, which accepts only the Base64 form.
  • The UUID is hidden from public for url friendliness purposes.
  • The site uses Cassandra 2 as it's main db.
  • Extra details to consider, there will also be other queries in the form of: find cats with X favourite food, Y enemies, ... this is however not what is being asked.

Questions

Knowing the data to be stored and how it will be queried, what would be the correct way to model it?

I had in mind a cat table, where each entry key is the UUID. And two separate lookup tables, one for the Base64 encoded strings and the other for the custom names.

The page controller would look if the url parameter is a Base64 String, if so first query the loookup table to get the UUID and then query the data table. If it's not, query the name lookup table and then the data. If not found in the lookup or data tables return 404.

Is there any problem with this approach? What should I consider? What other ways would you recommend?

I must say I'm new to Cassandra, any tips will help.

1

There are 1 best solutions below

3
On

If it is not too late into your development, I recommend just using sha-256 of the vanity URL as your id and do one lookup. With this approach, you have to make your interface such that it does not allow changing of vanity urls, after they are set, and you should make that a required field. This simplified your app alot.