I'm used to MySQL and now trying to grasp an understanding of how to use key value stores. What I have not seen are good noob like examples of database design and how you would insert and get information.
Is this a correct representation of how you would store data from MySQL in a key value store?
TYPE: MySQL
TABLE: users
COLUMNS: user_id(primary), username, location
TYPE: Key Value Store
TABLE: users
KEY: user_id
VALUES: username, location
So, if I am correct above. Pulling general user information is simple enough to understand. But how would I preform the following query in a key value store?
SELECT username FROM users WHERE location = 'mexico'
The way I thought you could do this easily is to create another table. (assume there are over 5,000 users, im sure there are other ways to do this if you only had a couple hundred)
--Original Table--
TYPE: Key Value Store
TABLE: users
KEY: user_id
VALUES: username, location
--Additional "query" Table--
TYPE: Key Value Store
TABLE: user-location
KEY: location
VALUES: user_id
However, now we need to adjust two tables when someone new joins, updates their location, etc. It's not a huge deal I suppose, you just have to be super accurate with your applications code.
Is this the best way to solve these problems? Or am I missing something?