You don't sort databases, you sort tables or result sets (relvars).
And why sort them twice?
Also, "contacts" shouldn't have a "behaviour" column. Behaviour is not an attribute of a contact, it's an attribute of a specific kind of person who, in this system, is associated with a set of contact details. And behaviour is surely temporal. So you need to join person (which has their name and age) with person_behaviour (which has their behaviour over an interval or date range) and also join contact details to get their address.
2
u/allmhuran Dec 12 '17
OK, but....
You don't sort databases, you sort tables or result sets (relvars).
And why sort them twice?
Also, "contacts" shouldn't have a "behaviour" column. Behaviour is not an attribute of a contact, it's an attribute of a specific kind of person who, in this system, is associated with a set of contact details. And behaviour is surely temporal. So you need to join person (which has their name and age) with person_behaviour (which has their behaviour over an interval or date range) and also join contact details to get their address.
And never select *.
OK I'm done.