July 24th, 2013, 08:49 AM
Target criteria -
I have a questions table
Now i want to give admin options to target specific people, i.e. Males, 18-25 and London.
target (q_id, target_type_id, criteria)
target_type (target_type_id, type)
I am not sure on how to go about the age? should i have another table with pre-defined age limits i.e. 18-25, 25-40 etc..
or i was thinking of just putting target_age, target_gender, target_location at the end of questions table?
Last edited by paulh1983; July 24th, 2013 at 08:53 AM.
July 24th, 2013, 10:40 AM
REF Table or Attribute
This depends on what you are trying to accomplish. If you are simply wanting to record the target's age, a person can only have one age so that one to one relationship would make it an attribute in your existing table.
However, if you want to have pre-determined bands of ages to make demographics you are creating a dimension as a ref table. The join conditions may be tricky here for the below reason.
The thing I'm most concerned about here is maintaining this data in a controlled way. Age is something that changes and people will change bands as they get older which requires a maintenance script or ETL process to run regularly to make sure every target is accurate.
For this reason I would recommend that you add a Date_Of_Birth attribute to your existing table. You can then create a view that does some date logic on the DOB field to make an age range column.
July 24th, 2013, 10:52 AM
yep i will be doing that but this topic is about QUESTION table not users table. i want to be able to show the question if user is say above 18 - 25 etc etc..
July 24th, 2013, 11:23 AM
When to ask the question
In that case, the way I would approach the problem is like this:
T_Age_Group(age_group_key, age_group_name, age_low, age_high)
V_Demographic(demographic_key,....., gender_key, age_group_key)
includes join on DOB logic which produces the age field between age_low and age_high
I like joining on surrogate keys i.e. the age_group_key so that your age group high/low values are allowed to change for whatever business reasons you may have in the future.
July 26th, 2013, 08:21 AM
cheers for that.
T_question = question table
T_target = USER?