sql - Creating a database table for storing filter criteria in MySQL -


i have problem. i've been banging head against wall 4 days now. know i'm missing something, i'm not sure is.

i'm trying store set of filter criteria. user of site see page can select different criteria filtering users of site (say twitter).

in page, there main criteria (which dropdown) : 1) tweeted @ (in case textfield appear next entering twitter handle) 2) had tweets more (in case number field appear next it) 3) tweeted between (in case 2 date fields 'from' , 'to' appear next it)

so basic flow : 1) user chooses 'tweeted at' main criteria 2) text input box appears next 3) user enters 'coldplay' 4) list of twitter users have tweeted @ coldplay returned

phew! ok, problem. i'm not sure how store filter criteria in table (say named filters).

i tried following :

  1. single table = col 1 - filter_id, col 2 - filter name, col 3 - tweeted_at (charfield), col 4 - no:of tweets (int field 'had tweets more than' option), col 5 - from_date, col 6 - to_date, col 7 - user_id. problem is, too, don't know wasteful (?). there 'null' values depending on main criteria chosen. seems bad design because if wanted add new criteria schema change. , don't think if had design schema change often. (ideally rows should increase/decrease not columns)
  2. split multiple tables :- 1) filterinstance - col 1 -filter_id, col 2 - value, col 3 - userid. 2)filterdefinition - col 1 - filter_id, col 2 - filter_name, col 3 - type. problem don't know data type have put 'value' in filterinstance. if put string if datatype date, i'd have go extracting mm/dd/yyyy manually. again, i'm stuck. fix schema changing problem.

so, i'd know how experienced people design structure table. know i'm missing something. don't know is. i'm implementing in django, if have idea specific django that'd ok guess. though ideally, wanna know if there cool way of structuring table.


edit : should mention i'd map user performed particular filter.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -