I'm trying to think of the best way to design a table for my database when I need a search screen.
Let's say I have a search screen of lastName, ssn, firstName, address.
I want a user to be able to search one to many of these fields, in every possible combination. Could be lastName only, ssn and address, etc. Some of these fields could be null in the database.
It seems this is very complicated without a relational database.
- I could either create a GSI for each field, query all four of them, and filter/combine results programatically.
- I could create a composite key, but that gets messy when you're searching in any possible order
- I could scan the whole table and filter things out myself
I can have tens of thousands of records at any given time. Each record contains a field with a very large JSON file in it that represents every UI field I have in my SPA, so each individual result could be a bit large. Although I suppose I don't need the JSON file returned on that query; just fields needed to populate a results table so the user can click a row, and then we look up JSON from there.
What would be the most performant, preferably inexpensive way to accomplish my needs using DynamoDB? Is there a simpler way other than my 3 proposed solutions? I previously used MongoDB queries in a DocumentDB, and could use AggregationOperations to do the search and Project a response. But, documentDB does not support an active-active global configuration, so I don't want to use it anymore for failover purposes.