I am writing some kind of resource management system.
A resource is an example of a definition. Definition is metadata, they mainly contain properties.
This is generally my DB:
TypeDefinition id name =============== 1 CPU PropertyDefinition id name typeDefinitionId valueType ================================================ 1 frequency 1 int 2 status 1 string TypeInstance id name typeDefinitionId ================================= 1 CPU#1 1 2 CPU#2 1 PropertyInstanceValue id propertyDefinitionId typeInstanceId valueType intValue StringValue FloatValue ======================================================================================== 1 1 1 int 10 2 2 1 string Pending 3 1 2 int 20 4 2 2 string Approved
DEMAND:
order all resources according to the value of a specific property .
For example: order all resources according to their status β The value of CPU # 2 will appear before CPU # 1, because "Approved" before "Pending".
If we ordered by frequency , CPU # 1 will appear in front of CPU # 2, because 10 to 20.
Therefore, I need to sort each time according to a different column (intValue / stringValue / FloatValue / etc), depending on the valueType property.
Any suggestion?
LIMITATION:
PIVOT is currently the only option we thought about, but it really is not, since the database is huge, and I need the request to be as fast as possible.
Thank you very much in advance,
Michal.
Michal
source share