Question

The queries listed below must be implemented with a set algebra operation. 1)Find the department name...

The queries listed below must be implemented with a set algebra operation.

1)Find the department name and code for all departments that only offered subjects that worth 6 credits. Note that a subject offered by a department means a lecturer of the department has been assigned to teach the subject.

CREATE TABLE LPOSITION(
   position       VARCHAR(20)   NOT NULL,   /* Position occupied       */
   salary_level   CHAR   NOT NULL,       /* Salary level   */
   CONSTRAINT LPosition_PKey PRIMARY KEY (position)
);

/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */

CREATE TABLE DEPARTMENT (
   name           VARCHAR(50)   NOT NULL,   /* Department name   */
   code           CHAR(8)       NOT NULL,   /* Code of department   */
   head           DECIMAL(7),               /* Head of department   */
   budget           DECIMAL(10,2),           /* Budget of department   */
   CONSTRAINT DEPARTMENT_PKey PRIMARY KEY (name)
);

/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */

CREATE TABLE EMPLOYEE(
   eno               DECIMAL(7)   NOT NULL,    /* Employee number       */
   first_name       VARCHAR(30)   NOT NULL,    /* First name           */
   last_name       VARCHAR(30)   NOT NULL,    /* Last name           */
   email           VARCHAR(50)   NOT NULL,    /* Email address       */
   bldg_no           DECIMAL(5)   NOT NULL,    /* Building number of office   */
   room_no           VARCHAR(5)   NOT NULL,    /* Office room number+suffix   */
   phone           DECIMAL(4)   NOT NULL,    /* Office phone extension number   */
   dname           VARCHAR(50)   NOT NULL,   /* Department name       */
   position       VARCHAR(20)   NOT NULL,    /* Position occupied   */
   CONSTRAINT EMPLOYEE_PKey PRIMARY KEY(eno),
   CONSTRAINT EMPLOYEE_CKey1 UNIQUE(email),
   CONSTRAINT EMPLOYEE_CKey2 UNIQUE(phone),
   CONSTRAINT EMPLOYEE_FKey1 FOREIGN KEY (dname) REFERENCES DEPARTMENT(name),
   CONSTRAINT EMPLOYEE_FKey2 FOREIGN KEY (position) REFERENCES LPOSITION(position)
);


/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */

CREATE TABLE SUBJECT(
   code             CHAR(7)           NOT NULL, /* Subject code       */
   title           VARCHAR(200)   NOT NULL, /* Subject title       */
   credits           DECIMAL(2)       NOT NULL, /* Credit points       */
   description       VARCHAR(2000)   NOT NULL, /* Subject description   */
   CONSTRAINT SUBJECT_PKey PRIMARY KEY(code)
);


/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
/* Association: RUNNING SUBJECT Is-instance-of SUBJECT           */

CREATE TABLE RUNNINGSUBJECT(
   code             CHAR(7)           NOT NULL, /* Subject code       */
   rsession       VARCHAR(7)       NOT NULL, /* Session running       */
   ryear           DECIMAL(4)       NOT NULL, /* Year running       */
   enrolment       DECIMAL(3)       NOT NULL, /* Total enrolment       */
   CONSTRAINT RUNNINGSUBJECT_PKey PRIMARY KEY(code, rsession, ryear),
   CONSTRAINT RUNNINGSUBJECT_FKey1 FOREIGN KEY (code)
       REFERENCES SUBJECT(code)
);


/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */

CREATE TABLE TEACHES(
   code             CHAR(7)           NOT NULL, /* Subject code       */
   rsession       VARCHAR(7)       NOT NULL, /* Session running       */
   ryear           DECIMAL(4)       NOT NULL, /* Year running       */
   lecturer       DECIMAL(7)       NOT NULL, /* Lecturer           */
   CONSTRAINT TEACHES_PKey PRIMARY KEY(code, rsession, ryear, lecturer),
   CONSTRAINT TEACHES_FKey1 FOREIGN KEY (code, rsession, ryear)
       REFERENCES RUNNINGSUBJECT(code, rsession, ryear),
   CONSTRAINT TEACHES_FKey2 FOREIGN KEY (lecturer) REFERENCES EMPLOYEE(eno)
);

Homework Answers

Answer #1

Hey! here is my answer.............please give positive Rating to appreciate my work...........

The queries listed below must be implemented with a set algebra operation.

1)Find the department name and code for all departments that only offered subjects that worth 6 credits. Note that a subject offered by a department means a lecturer of the department has been assigned to teach the subject.

CREATE TABLE DEPARTMENT (
   name           VARCHAR(50)   NOT NULL,   /* Department name   */
   code           CHAR(8)       NOT NULL,   /* Code of department   */
   head           DECIMAL(7),               /* Head of department   */
   budget           DECIMAL(10,2),           /* Budget of department   */
   CONSTRAINT DEPARTMENT_PKey PRIMARY KEY (name)
);

CREATE TABLE SUBJECT(
   code             CHAR(7)           NOT NULL, /* Subject code       */
   title           VARCHAR(200)   NOT NULL, /* Subject title       */
   credits           DECIMAL(2)       NOT NULL, /* Credit points       */
   description       VARCHAR(2000)   NOT NULL, /* Subject description   */
   CONSTRAINT SUBJECT_PKey PRIMARY KEY(code)
);

ANSWER:-   this query require 2 tables DEPARTMENT and SUBJECT

  • Query 1:-   ∏ DEPARTMENT.name, DEPARTMENT.codecredit = 6 ( σ DEPARTMENT.code = SUBJECT.code (DEPARTMENT x SUBJECT)))
  • Query 2:-   ∏ DEPARTMENT.name, DEPARTMENT.code ( σ DEPARTMENT.code = SUBJECT.code  credit = 6 (DEPARTMENT) x SUBJECT))

Thanks................for any query please ask ....

Know the answer?
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
Similar Questions
1) Add to a relational table DEPARTMENT information about the total number of employees in each...
1) Add to a relational table DEPARTMENT information about the total number of employees in each department. Note, that if a department has not employee then for such a department the total number of employees must be set to zero (0). The total number of employees must be a positive number no more than 999. Use SELECT statement to list the contents of an extended relational table DEPARTMENT in the descending order of the total number of employees. Finally, remove...
Perform SQL queries in the given data structure. write an SQL query that gives the number...
Perform SQL queries in the given data structure. write an SQL query that gives the number of courses taken for every student in the student table. For each instructor, show the instructor name and the number of sections that have been taught by that instructor. You do not need to include instructors who have never taught a section. List in order of decreasing the number of sections taught. Give the number of semester/year combinations in which sections have been offered....
Space X Bank CREATE TABLE Branch(BranchIDNumber VARCHAR(15) PRIMARY KEY NOT NULL, BranchName VARCHAR(6) NOT NULL, Address...
Space X Bank CREATE TABLE Branch(BranchIDNumber VARCHAR(15) PRIMARY KEY NOT NULL, BranchName VARCHAR(6) NOT NULL, Address VARCHAR(50) NOT NULL, City TEXT NULL, State CHAR(2) NULL, ZipCode INT(11) NOT NULL, OfficeNum VARCHAR(15) NOT NULL, FaxNum VARCHAR(15) NOT NULL); CREATE TABLE Employee(EmployeeIDNumber VARCHAR(15) NOT NULL,FirstName VARCHAR(35) NOT NULL, LastName VARCHAR(35) NOT NULL, Email VARCHAR(100) NOT NULL, BranchIDNumber VARCHAR(11) NOT NULL, FOREIGN KEY(BranchIDNumber) REFERENCES Branch(BranchIDNumber), JobTitle ENUM("Manager","Staff") NOT NULL, Salary DECIMAL(8, 2) NOT NULL, HomeNumber VARCHAR(13) NULL, CellNumber VARCHAR(13) NOT NULL); CREATE TABLE...
Assignment Instructions (MY WORK IN MYSQLBENCH)- Follow instructions in class to download and build a database...
Assignment Instructions (MY WORK IN MYSQLBENCH)- Follow instructions in class to download and build a database in your DBMS. Write and demonstrate queries (in-class) that do the following: Download the appropriate attached SQL file for your DBMS. Load the file into your database design tool and run it to build the Pine Valley Furniture Company database. This is the database that is used in the textbook examples for both Chapters 5 and 6. Write a query to show the price...
Find the total number of employees and the total number of dependents for every department (the...
Find the total number of employees and the total number of dependents for every department (the number of dependents for a department is the sum of the number of dependents for each employee working for that department). Return the result as department name, total number of employees, and total number of dependents Based on the following table: -- drop tables DROP TABLE EMPLOYEE CASCADE CONSTRAINTS; DROP TABLE DEPARTMENT CASCADE CONSTRAINTS; DROP TABLE DEPT_LOCATIONS CASCADE CONSTRAINTS; DROP TABLE PROJECT CASCADE CONSTRAINTS;...
Please create the queries listed below using the books database under question 4. Thanks for the...
Please create the queries listed below using the books database under question 4. Thanks for the help 1. List the number of books, the minimum price, maximum price, and average sales of history books. The format of output is: Number Min Price Max Price Average Sale 2. List the number of books and the average number of pages published by pub_id P01. 3. List the number of books and the total sales of the books with price greater than $15....
Create 2 stored procedures: sp_AddNewUser and sp_AddNewRole. Use the ManyToMany script as your base table structures....
Create 2 stored procedures: sp_AddNewUser and sp_AddNewRole. Use the ManyToMany script as your base table structures. The stored procedure should accept the parameters needed to input the data for each table. NOTE: You do not need to input the UserID or RoleID. These are surrogate keys and the system automatically inserts them when you insert a row in the tables.   On execution, the stored procedure should check the database to see if the user exists, if so, return a message...
1. For the Pet Database described in the previous practical, write an SQL statement with a...
1. For the Pet Database described in the previous practical, write an SQL statement with a subquery to list all the people in the Owner table who own more than one pet. should be a collum of the total number of pets owned, owner id, first name and last name -- DROP TABLE PetAndOwner, Pet, PetType, Owner; CREATE TABLE PetType ( petTypeId VARCHAR(10) PRIMARY KEY, animalType VARCHAR(20), breed VARCHAR(20) ); CREATE TABLE Owner ( ownerId VARCHAR(10) PRIMARY KEY, firstName VARCHAR(20),...
1.Consider the following (normalized) relational model (primary keys are underlined, foreign keys are in italics). EMPLOYEE(SSN,...
1.Consider the following (normalized) relational model (primary keys are underlined, foreign keys are in italics). EMPLOYEE(SSN, ENAME, EADDRESS, SEX, DATE_OF_BIRTH, SUPERVISOR, DNR) S U P E R V I S O R : foreign key refers to SSN in EMPLOYEE, NULL value allowed D N R : foreign key refers to DNR in DEPARTMENT, NULL value not allowed DEPARTMENT(DNR, DNAME, DLOCATION, MGNR) MGNR: foreign key refers to SSN in EMPLOYEE, NULL value not allowed PROJECT(PNR, PNAME, PDURATION, DNR) DNR: foreign...
SQL Data: you can just copy paste it into mysql to. CREATE DATABASE University;USE University; CREATE...
SQL Data: you can just copy paste it into mysql to. CREATE DATABASE University;USE University; CREATE TABLE Student (  sid INT PRIMARY KEY,  name VARCHAR(20) NOT NULL,  address VARCHAR(20) NOT NULL,  major CHAR(2)); CREATE TABLE Professor (  pid INT PRIMARY KEY,  name VARCHAR(20) NOT NULL,  department VARCHAR(10) NOT NULL); CREATE TABLE Course (  cid INT PRIMARY KEY,  title VARCHAR(20) NOT NULL UNIQUE,  credits INT NOT NULL,  area VARCHAR(5) NOT NULL); CREATE TABLE Transcript (  sid INT,  cid INT,  pid INT,  semester VARCHAR(9),  year YEAR,  grade CHAR(1) NOT NULL,  PRIMARY KEY (sid, cid, semester, year),  FOREIGN KEY (sid) REFERENCES Student...