And So I want my customers to have the ability to restrict who may contact them.
You will find several factors they ought to have the ability to filter, including Age (e.g. Should be between 18 - 29), earnings (must earn between $25,000 - $60,000), what they are searching for (e.g. Friendship, Spend time, etc.), what drugs they are doing (Marijuana, Meth, Cocaine, etc), etc.
The issue is, I would like these to have the ability to choose and store multiple options for a few of the criteria (e.g. drugs), but I don't understand how I ought to store that within the DB or the way i should structure the table to best accomplish this.
For instance, wouldso would I store a user's row that for "drugs" chose "Marijuana", "Cocaine", and "Heroin" in this particular context? Would I merely store individuals as comma-separated values within the "Drugs" column? Or must i get it done inside a different way?
An amount be the easiest method to do that (thinking about I'll clearly need to retrieve and appearance these details whenever a user really wants to contact another user) and why?
No, don't keep values in CSV format within the database. Rather produce a join table known as
user_drug and store one row for every user/drug combination:
user id name income 1 Foo 10000 2 Bar 20000 3 Baz 30000 drug id name 1 Marijuana 2 Cocaine 3 Heroin user_drug user_id drug_id 1 1 1 2 2 1 2 3 3 3
You can test with this particular:
criterium ------------ user_id type value 1 AGE_MIN 18 1 AGE_MAX 29 1 INCOME_MIN 25000 1 INCOME_MAX 60000 1 DRUGS Marijuana 1 DRUGS Meth
A DB column (a minimum of theorethically) should NOT hold multiple values. Regrettably, you will find some developers that store multiple values in one column (values separated by comma for good examples) - individuals developers (generally) destroy the idea of DB and SQL.