HN user

any626

24 karma
Posts0
Comments8
View on HN
No posts found.

Depends

You could have

    property_id, user_id, value(string)
    1 (assume age), 1213,    60
    2 (gender),     1213,    female
or
    property_id, user_id, value_str, value_int
    1 (assume age), 1213,    null, 60
    2 (gender),     1213,    female, null
or have a mapping in the application to get the type of the property. Plenty of ways to handle it.

You would need to have a new join for each new property

    SELECT DISTINCT loyaltyMemberID
    from members as m
    INNER JOIN properties as p1 on m.id = p1.user_id
    INNER JOIN properties as p2 on m.id = p2.user_id
    INNER JOIN properties as p3 on m.id = p3.user_id
    AND (p1.prop = 'gender' AND p1.value = x)
    AND ((p2.prop = 'age' AND p2.value = y) OR (p3.prop = 'censor' AND p3.value = z))

The user data is most likely in rows instead of columns. Instead of having

    id, name, age, gender
    1213, fake, 60, female
they would have
    property_id, user_id, value
    1 (assume age), 1213,    60
    2 (gender),     1213,    female
This gives them the freedom to add more properties to the user without always having to add a column to the users table. When querying the database you'll have to do unions or joins.