Question

Consider the following relational schemas: Employee (eid: integer, ename: string, Job_title: string, Years_of_experience: integer) Project (pid:...

Consider the following relational schemas: Employee (eid: integer, ename: string, Job_title: string, Years_of_experience: integer) Project (pid: integer, pname: string, parea: string, mid: integer, budget: integer) Works_on (eid: integer, pid: integer) Manger (mid: integer, mname: string, deptid: integer) The meaning of these relations is straightforward; for example, Works_on has one record per Employee-Project pair such that the Employee Works_on the Project. 1. Write the SQL statements required to create these relations, including appropriate versions of all primary and foreign key integrity constraints. 2. Write the following query in SQL. For each Manger that supervise only ‘Networking’ projects, print the Manger member’s name and the total number of Projects she or he has supervised. 3. Express each of the following integrity constraints in SQL unless it is implied by the primary and foreign key constraint; if so, explain how it is implied. If the constraint cannot be expressed in SQL, say so. For each constraint, state what operations (inserts, deletes, and updates on specific relations) must be monitored to enforce the constraint. (a) Every Project has a minimum enrollment of 5 Employees and a maximum enrollment of 30 Employees.(b) Every Manger must supervise at least two projects. (c) Only employees with at least 3 Years_of_experience can work in more than 3 projects.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Given relations are:

Employee (eid: integer, ename: string, Job_title: string, Years_of_experience: integer)

Project (pid: integer, pname: string, parea: string, mid: integer, budget: integer)

Works_on (eid: integer, pid: integer)

Manger (mid: integer, mname: string, deptid: integer)

Employee table:

CREATE TABLE Employee (
eid int not null,
ename varchar(255),
job_title varchar(255),
years_of_experiance int,
primary key(eid),
  
);

project table:


CREATE TABLE Project (
pid int not null,
pname varchar(255),
parea varchar(255),
mid int,
budget int,
primary key(pid),
FOREIGN KEY (mid) REFERENCES Manager(mid)
);

CREATE TABLE Works_on (
eid int not null,
pid int not null,
FOREIGN KEY (eid) REFERENCES Employee(eid)
FOREIGN KEY (pid) REFERENCES projrct(pid)
  
);


CREATE TABLE Manager(
mid int not null,
mname varchar(255),
parea varchar(255),
deptid int,
primary key(mid),
  
);

2) select m.mname,p.count(pid) from manager m,Project p where m.mid=p.mid and project like '%Networking'.

Add a comment
Know the answer?
Add Answer to:
Consider the following relational schemas: Employee (eid: integer, ename: string, Job_title: string, Years_of_experience: integer) Project (pid:...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Answer each of the following questions. The questions are based on the following relational schema: Emp(*eid:...

    Answer each of the following questions. The questions are based on the following relational schema: Emp(*eid: integer¬, ename: string, age: integer, salary: decimal, doj: date) Works(*eid: integer, *did: integer, no_of_hours: integer) Dept(*did: integer, dname: string, budget: real, managerid: integer) a) Give an example of a foreign key constraint that involves the Dept relation. b) What are the options for enforcing this constraint when a user attempts to delete a Dept tuple? c) Define the Dept relation in SQL so that...

  • Consider a database schema consisting of two tables, Employee (ID, Name, Address), Project(PID, Name, Deadline), Assign...

    Consider a database schema consisting of two tables, Employee (ID, Name, Address), Project(PID, Name, Deadline), Assign (EID, PID, Date). Assign.EID is a foreign key referencing employee's ID and Assign.PID is a foreign key reference the project. Write the SQL query for 1. Find Projects that are not assigned to any employees(PID and Name of the project).

  • Consider the following relations: Patient (pid: integer, lname: string, fname: string, primary_did: integer, age: integer) Doctor...

    Consider the following relations: Patient (pid: integer, lname: string, fname: string, primary_did: integer, age: integer) Doctor (did: integer, lname: string, fname: string, deptid: integer, age: integer, salary: integer) Nurse (nid: integer, lname: string, fname: string, deptid: integer, rank: string, age: integer) Department (deptid: integer, name: string, budget: integer) Menu (menuid: integer, pid: integer, caloriecount: integer, saltlevel: integer, vegetarian: bit, diabetic: bit, nauseaSafe: bit, notes: string) Vaccination (vaccinationid: integer, pid: integer, vaccinationname: string, dategiven: date, dateexpires: date) Prescription (presid: integer, pid:integer,...

  • Any help appreciated! Question 1 (5 points). Answer each of the following questions briefly. The questions...

    Any help appreciated! Question 1 (5 points). Answer each of the following questions briefly. The questions are based on the following relational schema: Emp( eid: integer, ename: string, age: integer, sala1l1: real) Works( eid: integer, did: integer, pet_time: integer) Dept(did: integer, dname: string, budget: real, managerid: integer) 1. Give an example of a foreign key constraint that involves the Dept relation. 2. Write the SQL statements required to create the preceding relations, including appropriate versions of all primary and foreign...

  • Consider the database consisting of the following relations: Flights(Fl#: integer, From: string, To: string, Distance: integer,...

    Consider the database consisting of the following relations: Flights(Fl#: integer, From: string, To: string, Distance: integer, departs: Time, Arrives: time) Flight Instance(Fl#: integer, Day: date, Aid: Integer) Aircraft(Aid: integer, Make: string, Model: string, CrusingRange: string) Certified(Eid: integer, Make: string, Model: string) Employee(Eid: integer, Ename: string, Salary: integer) Fight Attendant(Fl#: integer, Day: date, Eid:integer, Role: string) The Flight table contains general information about the flights whereas the Flight Instance is about a flight number on a specific date. Aircraft list the...

  • Consider the following database Relation Schemas: Relation Schemas: Suppliers(SID CHAR(5), Parts(pID VARCHAR(5), type VARCHAR(15), pName VARCHAR(35),...

    Consider the following database Relation Schemas: Relation Schemas: Suppliers(SID CHAR(5), Parts(pID VARCHAR(5), type VARCHAR(15), pName VARCHAR(35), sName VARCHAR(15), address VARCHAR(30, city VARCHAR(20), state CHAR(2), PRIMARY KEY(sID); PRIMARY KEY(pID) Catalog(sID CHAR(5), pID VARCHAR(5), ty SMALLINT, cost FLOAT (10,2), PRIMARY KEY(sid, pid), FOREIGN KEY(sid) REFERENCES Suppliers(SID), FOREIGN KEY (pid) REFERENCES Parts pID) The meaning of these relations is straightforward; for example, the Catalog relation lists the prices charged for parts by Suppliers. Instances of the relations Suppliers sName address SID cit state...

  • Write SQL Queries Given the following tables (7pts) Retrieve the names of employees and their project...

    Write SQL Queries Given the following tables (7pts) Retrieve the names of employees and their project name. If the employee never worked on a project, show the names only the name, not the project name. (7pts) Retrieve the names of employees who have worked on the same project at a different location. (7pts) Retrieve the names of employees who have worked on more than two different projects. (7pts) Retrieve the names of employees who manage more than two employees. CREATE...

  • Consider the following relational schema. An employee can work in more than one department; the pct...

    Consider the following relational schema. An employee can work in more than one department; the pct time field of the Works relation shows the percentage of time that a given employee works in a given department. Emp(eid: integer, ename: string, phone: integer, salary: real) Works(eid: integer, did: integer, pct_time: integer) Dept(did: integer, dname: string, budget: real, managerid: integer) Write the following SQL queries. d) Find the enames of managers who manage the departments with the largest budgets. e) Find the...

  • Consider the following relational schema. An employee can work in more than one department; the p...

    Consider the following relational schema. An employee can work in more than one department; the pct_time field of the Works relation shows the percentage of time that a given employee works in a given department. Emp(eid: integer, ename: string, age: integer, salary: real) Works(eid: integer, did: integer, pct_time: integer) Dept(did: integer, budget: real, managerid: integer) In the above, please note that there is an attribute pcttime (of Integer type) in the Works table, as the schema shows. A tuple/row <1,...

  • Suppose a database has the following three relations. Museum (mid: integer, name: string, address: string, website:...

    Suppose a database has the following three relations. Museum (mid: integer, name: string, address: string, website: string) Displays (museumID: integer, artID: integer, startDate: date) ArtItem (aid: integer, title: string, weightPnd: integer, type: string) Artist (pid: integer, firstname: string, lastname: string, birthdate: date, deathdate: date) Creates (artistID: integer, artID: integer, year: integer) (The "bit" data type stores 0 or 1. False or true. Booleans.) "museumID" in Displays is a foreign key referencing "mid" in Museum. "artistID" in Creates is a foreign...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT