Question: The Enterprise database Consider an enterprise database which stores information about companies, employees and projects. The relational schema employee (id, name, address) stores information about

 The Enterprise database Consider an enterprise database which stores information about

The Enterprise database

Consider an enterprise database which stores information about companies, employees and projects.

The relational schema employee(id, name, address) stores information about employees; namely their unique id, name and address.

The relation schema company(id, name, address) stores information about companies; namely their unique id, name and address.

The relation schema project(id, name, budget) stores information about projects; namely their unique id, name and budget.

The relation schema salary(employee_id, year, salary) stores additional information about employees; namely what their salaries were at a given year. Hence, employee_id is a foreign key in salary and it references id in employee.

The relation schema manages(manager_id, employee_id) stores information about pairs of employees; namely whether one employee is the manager of the other employee. Hence, manager_id and employee_id are foreign keys in manages and both reference id in employee.

The relation schema worksFor(employee_id, company_id) stores information about employees and companies; namely which employees work for which companies. Hence, employee_id and company_id are foreign keys in worksFor, where employee_id references id in employee and company_id references id in company.

The relation schema worksOn(employee_id, project_id) stores information about employees and projects; namely which employees work on which projects. Hence, employee_id and project_id are foreign keys in worksOn, where employee_id references id in employee and project_id references id in project.

When writing various types of expressions, we will sometimes abbreviate:

employee_id as eid, company_id as cid, project_id as pid, and manager_id as mid

Question 5 1.4 pts Consider the Enterprise database schema. Suppose we want to check for any management cycles. Informally, a management cycle is a chain of employees that starts and ends with the same employee and each employee in the chain manages the previous employee. Formally, it is any instantiation of the pattern managesleid1, eida) manages(eid2, eid 3)... manages (eidn-2, eidn - 1) manages(eidn-1, eidn) such that eid 1 = eidn. Which of the following Datalog queries return all those employees and only those employees that are part of a management cycle? Multiple answers can be correct. mc(X,Y) :-manages(X, Z), manages(Z,Y) mc(X, Y):- mc(X, Z), mc(Z,Y) c(X):- mc(X, X) ? c(X) mc(X,Y) :- manages(X, Y) mc(X, Y):- mc(X, Y), manages(Y,Z) c(X) :- mc(X, X) ? c(X) None of the other options is correct mc(X,Y):- manages(X,Y) mc(X, Y):- mc(X, Z), mc(Z,Y) c(X):- mc(x,x) ? c(X) mc(X,Y) :- manages(X,Y) mc(X,Y) :- mc(X, Z), manages(Z,Y) c(X) :- mc(X,X) ? c(X) mc(X,Y) :- manages(X, Y) mc(X, Y):- mc(X, Y), mc(Y,Z) c(X):- mc(x,x) ? c(X)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!