0

I'm not sure how the following is an unsafe query. "Unsafe query" means that the answer set is infinite. I seek an explanation of why it is an unsafe query because I don't understand the query.

There are 2 tables:

invoice

number(PK)    customer   date         amount
12343         121        24/4/11      123455
23432         234        1/3/11       3234
23456         121        12/4/11      12540
67891         121        1/4/11       1432
19473         234        11/12/11     555

customer

code(PK)    name     address
121         a        ab
234         b        bc
233         c        cd
122         d        de

The query is:

{< X1, Z2 > |
    ƎY1, ƎZ1, ∀X2, ∀V2 (
            customer(X1, Y1, Z1)
        ᴧ  (invoice(X2, X1, Z2, V2) --> Z2 >= '1/4/11')
    )
}
philipxy
  • 14,867
  • 6
  • 39
  • 83
user1097856
  • 159
  • 3
  • 15
  • That's not SQL. That's a school assignment so you'll have to explain what you mean by `unsafe query` – Panagiotis Kanavos Nov 29 '13 at 14:25
  • You have nothing to do with SQl. its purely DRC for DBMS. I suspect you end up in cartesian join, which is unsafe. – Srini V Nov 29 '13 at 14:30
  • thanks. have edited the post. The main reason is that I don't quite understand the query. – user1097856 Nov 29 '13 at 14:51
  • Safety is not re avoiding infinities, it is re syntactically avoiding values not in the database or a query. With all domains finite there are still unsafe queries. Find a *clear precise definition* of safety & *algorithms* to determine whether a query is safe. You will have been given references; what are they? They don't require "understanding the query". Also, safety is usually presented as a *tuple calculus* concept. PS Cartesian product of two safe expressions is safe. If it made sense to say an operator was unsafe, it would be safe. – philipxy Apr 14 '17 at 03:49

0 Answers0