Menu

Enterprise Database Consider Enterprise Database Stores Information Companies Employees Pr Q43810223(1)

Question 5 1.4 pts Consider the Enterprise database schema. Suppose we want to check for any management cycles. Informally, a

The Enterprise database

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

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

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

The relation schema project(id, name,budget) stores information about projects; namely their uniqueid, 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 insalary and it references id inemployee.

The relation schema manages(manager_id,employee_id) stores information about pairs of employees;namely whether one employee is the manager of the otheremployee.
Hence, manager_id and employee_id are foreignkeys in manages and both referenceid 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 foreignkeys in worksFor, whereemployee_id references id inemployee and company_idreferences 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 foreignkeys in worksOn, whereemployee_id references id inemployee and project_idreferences id in project.

When writing various types of expressions, we will sometimesabbreviate:

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) Show transcribed image text 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)

Expert Answer


Answer to The Enterprise database Consider an enterprise database which stores information about companies, employees and projects…

OR