I've got a usersystem. Every user has a profile. Profile fields are dynamically stored in the database. The database looks like:
CREATE TABLE profileFields(
profileField_id INT(255) AUTO_INCREMENT,
profileField_name VARCHAR(255),
profileField_value VARCHAR(255),
profileField_type VARCHAR(255),
profileField_isOptional TINYINT(1),
PRIMARY KEY(profileField_id)
);
CREATE TABLE users(
user_id INT(255) AUTO_INCREMENT,
user_username VARCHAR(255),
user_password VARCHAR(255),
user_email VARCHAR(255),
PRIMARY KEY(user_id)
);
CREATE TABLE profileValues(
profileValue_id INT(255) AUTO_INCREMENT,
profileValue_profileField_id INT(255),
profileValue_user_id INT(255),
profileValue_value VARCHAR(255),
PRIMARY KEY(profileValue_id)
);
I'm trying to get a list of all users with all profile fields and values. I've got a total of 50.000 users and 60 profile fields, resulting in 3.000.000 profile values.
What would be the most efficient way to retrieve such a list (and possibly perform searches based on the profile fields)?