tailieunhanh - Applied Mathematics for Database Professionals phần 7

Nếu trong quá trình viết lại biểu thức, bạn sẽ truy vấn nhân viên không có một mức lương ít hơn 5000, nó có thể được tốt hơn để truy vấn các nhân viên có mức lương bằng hoặc hơn 5000 thay vì. Viết lại quy tắc sau đây được áp dụng (e đại diện cho một tuple nhân viên): ¬ (e (MSAL) | 218 CHAPTER 9 DATA RETRIEVAL If in the course of rewriting expressions you end up querying employees who don t have a salary of less than 5000 it might be better to query the employees who have a salary equal to or more than 5000 instead. The following rewrite rule applies e represents an employee tuple -i e MSAL 5000 e MSAL 5000 Our brains dislike negations. Try to avoid negations by rewriting expressions into expressions containing fewer negations. This is not only true for query specifications but also for constraint specifications in previous chapters and data manipulation specifications in the next chapter . Chapter Summary This section provides a summary of this chapter formatted as a bulleted list. You can use it to check your understanding of the various concepts introduced in this chapter before continuing with the exercises in the next section. Queries constitute a crucial application of a database they enable you to extract information from a database that is relevant for you. You can formally represent a query as a function over a database universe. For every database state that you supply as the argument the function returns the query result. Because you supply a database state the function can reference every table available in the database state to determine the query result. To specify a query you can use all formal concepts introduced in Part 1 of this book. You usually specify the result set of a query as a set of tuples a table using the hybrid method. The given set from which you start such a specification is typically one of the tables or a join of some of the tables available in the database state you can also use any of the set operators introduced in this book. The predicates inside the query specification are typically compound predicates they use the various logical connectives and often employ the universal and existential quantifiers. In practice certainly when you use SQL the result of a query will always be a table. However our formal