Thursday, December 22, 2011

6 Simple types of Inverted Queries

Whatever kind of database you are working on - NoSql, ORM, relational, or OO you will still need to query for data.

There are two ways in which data can be queried. The first way is for each entity to have a identifying or unique attribute. This identifying or unique attribute then can be used to select the entity or entities. The second way is an inversion of the first and is designed so that the entity identifiers associate with a given attribute may be obtained. The first way is useful for answering the question: What are the properties of a given entity? The second is useful for answering: What entities have a given property?

Assuming that we have entities E; attributes, A; and their attribute values, V. We have these 6 types:

Form Type of Query Example
Common attribute inquiry How much did Saleman No. 15 earn last month?
Which entities have the given value? Which salesman or men earned more that 20,000 last month?
List all attributes having a given set of values for a given entity Which month's earnings for Salesman No. 15 have exceeded 20,000?
Request for all information about a given entity List all the information stored about Saleman No. 15
List the value of a given attribute for every entity List last month's earnings for every salesman
List all entity attributes having a given set of values For every salesman, list every month when this earnings exceeded 20,000
You can mix and match the six types to create very complex queries. You could for example ask the question: Which salesman earned more that 20,000 in May OR June OR July?

No comments:

Post a Comment