Let me clarify what I am trying to do, as I realize I wasn't clear in the previous message. Hopefully someone could tell me what I am doing wrong, or how to do it differently
I have 3 people:
ID: 5234
Last name: "Smith"
Birth Date: "4/3/70"
Privacy: 'enabled'
ID: 9312
Last name: "Becker"
Birth Date: "before 1970"
Privacy: 'disabled'
ID: 23
Last name: "Davidson"
Birth Date: "March 1966"
Privacy: 'disabled'
Note that the birth date attribute must be a varchar, as it may contain textual dates.
Because I cannot count on MySQL to correctly sort people by date (system requirement), and because the data doesn't change in runtime (system requirement), I thought I would pre-sort all the data myself and just store the sorted IDs in a separate table, called: sorted_people.
Here is what the table would look like for such data:
sorted_people:
By_Lastname: 9312, 23, 5234
By_Birthdate: 23, 9312, 5234
The order of the IDs in each column defines the correct order of the people when sorted in that criteria.
The last complication comes from the definition of privatization:
Each person can be either privatized or not (defined by the Privacy attribute).
There is also a system-wise table which defines what attributes are to be privatized.
for example:
privacy_settings:
shouldPrivatizeLastName = 'no'
shouldPrivatizeBirthdate = 'yes'
In order for a person to be privatized on last name (for example) his privacy_level should be set to 'enabled' AND the system shouldPrivatizeLastName attribute should be set to 'yes'
privatized people should be displayed last. Non-privatized people should be displayed according to the order defined in the appropriate column in the sorted_people table.
please help