This preview shows pages 1–5. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: Recall from last time: Recall from last time: Queries expressed using first order logic Queries expressed using first order logic The example scenario: Student(name, college, major, gpa) Faculty(name, dept, salary, year_hired) Chair(dept, name) Teaches(name, course) Enrolls(name, course) List the names of faculty that have the highest salary in their department (d, s, y) (Faculty(n, d, s, y) (n1, s1, y1) (Faculty(n1, d, s1, y1) (s s1))) or we could say (d, s, y)( Faculty(n, d, s, y) ( n1, s1, y1) (Faculty(n1, d, s1, y1) (s < s1))) Remember: P Q P Q DeMorgans Law: (A B) ( A ) ( B ) Queries in Domain Relational Calculus in text Queries in Domain Relational Calculus in text notation notation Each query is an expression of the form: { < x 1 , x 2 , , x n >  P ( x 1 , x 2 , , x n )} x 1 , x 2 , , x n represent domain variables P represents a formula similar to that of the predicate calculus Text example schema: branch ( branch_name, branch_city, assets ) customer ( customer_name, customer_street, customer_city ) account ( account_number, branch_name, balance ) loan ( loan_number, branch_name, amount ) depositor ( customer_name, account_number ) borrower ( customer_name, loan_number ) And an example query in text notation: And an example query in text notation: Find the names of all customers having a loan, an account, or both at the Perryridge branch: { < c >  l ( < c, l > borrower b,a ( < l, b, a > loan b = Perryridge ) ) a ( < c, a > depositor b,n ( < a, b, n > account b = Perryridge ) ) } Notice the form of the query: { < x 1 , x 2 , , x n >  P ( x 1 , x 2 , , x n )} x 1 , x 2 , , x n represent domain variables P represents a formula similar to that of the predicate calculus Notice that in all of the DRC queries, we had to pay attention to the order of the columns as we framed the query. we had to remember, for example, that the first column of the loan relation is the loan_number, the second the branch_name, the third the amount that means that we effectively need to keep the details of the relation schema in our heads all the time down to the order of the columns this is a pain!...
View Full
Document
 Spring '08
 Conry

Click to edit the document details