Pages: 2
Rating : ⭐⭐⭐⭐⭐
Price: $10.99
Page 1 Preview
the sort attribute not the list requested attribut

The sort attribute not the list requested attributes


Chapter 4 A Closer Look at Select

The thing to realize is that there is no real item named “Domain” with an attribute named“Count.” This is just SimpleDB formatting the count data into the existing response format.

In a WHERE clause, you define a set of criteria, and only items that match all the criteria are returned. For example:

SELECT * FROM users WHERE `last-name` = 'Smith'

SELECT * FROM users WHERE lastname = "O'Reilly"

SELECT * FROM users WHERE displayname = 'Mikki "The Great" Larkin'

These two rewritten examples are functionally identical to the preceding two.The choice of quote character has no bearing on the outcome of the Select. It is merely a mat-ter of preference or convenience.

Sort Clause

SELECT name, score FROM tests WHERE score < '75' ORDER BY score

This is the same as the prior Select example, but now the results will come back sorted on the value of the score attribute.The default sort direction is ascending if no di-rection is given.

Because SimpleDB never enforces any form of required attributes, your sort attribute might not exist in all items that match your query. If this were to happen, SimpleDB would not re-ally have a meaningful way to order your search results. You could argue that items without the sort attribute should just be included at the end of the results, following the properly sorted results. However, inclusion at the end does nothing to solve the ordering problem be-tween those items at the end. Moreover, what is worse, if the sort attribute is not in the list of requested attributes, there would be no way of knowing which of the result items had the sort attribute and which did not.

SimpleDB prevents these issues by only accepting a sort when the accompanying WHERE clause guarantees the presence of the sort attribute. Constructing such a WHERE clause is not difficult. In fact, merely including the sort attribute in a comparison will usually be suffi-cient to meet this requirement. The preceding example does just this:

You are viewing 1/3rd of the document.Purchase the document to get full access instantly

Immediately available after payment
Both online and downloadable
No strings attached
How It Works
Login account
Login Your Account
Place in cart
Add to Cart
send in the money
Make payment
Document download
Download File

Uploaded by : Hannah Powers

PageId: ELI9D1DA7E