Beispiel #1
0
def query_c():
    tmp_result = select(SUPPLY, "pid", "=", "p15")
    tmp_result = join(tmp_result, "sid", SUPPLIERS, "sid")
    query_result = project(tmp_result, ["address"])
    removeTable("Supply_tmp")
    removeTable(tmp_result)
    return query_result
Beispiel #2
0
def query_e():
    tmp_result = select(SUPPLY, "cost", ">=", 47.00)
    tmp_res1 = join(tmp_result, "pid", PRODUCTS, "pid")
    tmp_res2 = join(tmp_res1, "sid", SUPPLIERS, "sid")
    query_result = project(tmp_res2, ["sname", "pname", "cost"])
    removeTable("Supply_tmp")
    removeTable(tmp_res1)
    removeTable(tmp_res2)
    return query_result
Beispiel #3
0
def query_d():
    tmp_res1 = select(SUPPLIERS, "sname", "=", "Kiddie")
    tmp_res2 = select(SUPPLY, "pid", "=", "p20")
    tmp_result = join(tmp_res1, "sid", tmp_res2, "sid")
    query_result = project(tmp_result, ["cost"])
    removeTable("Suppliers_tmp")
    removeTable("Supply_tmp")
    removeTable(tmp_result)
    return query_result
Beispiel #4
0
def query_b():
    tmp_result = select(SUPPLIERS, "sid", "=", "s23")
    query_result = project(tmp_result, ["sname"])
    removeTable("Suppliers_tmp")
    return query_result
Beispiel #5
0
from program.relAlg import project
from program.display import displayTable, write_query

supplier_string = "Suppliers"
product_string = "Products"
supply_string = "Supply"
sid_attr = "sid"
pid_attr = "pid"
query_result_txt = "queryResult.txt"
print()

# query-1
print("Query a costs")
result = select(supplier_string, sid_attr, "=", "s23")
# print(result)
file = project(result, "sname")
# print(file)
write_query(
    "Query a - Find the name for the supplier ‘s23’ when a B+_tree exists on Suppliers.sid."
)
displayTable(file, query_result_txt)
print()

# query-2

print("Query b costs")
result = select(supplier_string, sid_attr, "=", "s23")
# print(result)
file = project(result, "sname")
# print(file)
write_query(