--- Paper Review
drop table paper_review cascade constraint;
drop table paper_author cascade constraint;
drop table paper cascade constraints;
drop table author cascade constraints;
drop table reviewer cascade constraints;
create table reviewer (
rid int, --- reviewer id
rname varchar(50), --- reviewer name
remail varchar(50),-- reviewer email
raffiliation varchar(50),-- reviewer affiliation
primary key (rid)
);
insert into reviewer values(1,'Alex Golden', '[email protected]','UMBC');
insert into reviewer values(2,'Ann Stonebraker', '[email protected]','UMD');
insert into reviewer values(3,'Karen Smith', '[email protected]','UMB');
insert into reviewer values(4,'Richard Wallas', '[email protected]','UMBC');
insert into reviewer values(5,'Ravi Krishnan', '[email protected]','JHU');
create table author
(aid int, -- author id
aname varchar(50), -- author name
aemail varchar(50), -- author email
aaffiliation varchar(50),-- author affiliation
primary key(aid));
insert into author values(1,'Adam Smith', '[email protected]','UMBC');
insert into author values(2,'Nancy Chang', '[email protected]','UMD');
insert into author values(3,'Carrol Steinberg', '[email protected]','UMB');
insert into author values(4,'Daniel Kerry', '[email protected]','JHU');
create table paper(
pid int,--- paper id
ptitle varchar(200),--- title of paper
corr_aid int, --- id of corresponding author, only one per paper
sub_date date, --- date of submission
primary key(pid),
foreign key(corr_aid) references author);
insert into paper values(1,'A novel intrusion detection method using deep learning', 1,date '2018-3-1');
insert into paper values(2,'A comparison study of different machine learning methods', 2,date '2018-3-2');
insert into paper values(3,'The benefits of exercises to dementia patients', 3,date '2018-4-3');
insert into paper values(4,'This paper has everyone has author', 3,date '2018-4-3');
create table paper_author
(
pid int,--- paper id
aid int,--- author id, corresponding author will also appear in paper_author table
primary key(pid, aid),
foreign key(pid) references paper,
foreign key(aid) references author
);
insert into paper_author values(1,1);
insert into paper_author values(1,2);
insert into paper_author values(2,2);
insert into paper_author values(2,1);
insert into paper_author values(3,3);
insert into paper_author values(3,4);
insert into paper_author values(4,1);
insert into paper_author values(4,2);
insert into paper_author values(4,3);
insert into paper_author values(4,4);
create table paper_review
(
pid int,-- paper id
rid int,--- reviewer id, each paper has multile reviewer assigned, same reviewer
-- can review multiple papers
content varchar(1000), --- content of review
rscore int, --- review score, 1-5
rdate date, --- review date
primary key(pid, rid),
foreign key(pid) references paper,
foreign key(rid) references reviewer
);
insert into paper_review values(1,1,'This is a great paper',5,date '2018-4-1');
insert into paper_review values(1,2,'Execclent paper',4,date '2018-3-28');
insert into paper_review values(2,3,'Nice paper',4,date '2018-4-1');
insert into paper_review values(2,1,'Good paper but I have question regarding figure 2',3,date '2018-4-2');
insert into paper_review values(3,3,'Interesting results',4,date '2018-5-2');
insert into paper_review values(3,4,'Timely paper',4,date '2018-5-3');
commit;
Problem: Please write a PL/SQL procedure to print out names of reviewers who are eligible to review a paper. Please pay attention to the following:
The input is the id of the paper.
A reviewer will be eligible to review a paper if the reviewer does not have the same affiliation as any of the authors of the paper. For example, for paper ID 1, there are two authors Adam Smith and Nancy Chang, their affiliations are UMBC and UMD. So any reviewer affiliated with those two schools cannot serve as reviewer.
Please also handle the case the input paper ID is invalid.
If there is no eligible reviewer, print out a message there is no eligible reviewer.
create or replace
PROCEDURE ReviewCheckName (id IN paper.pid%type)
AS
Reviewer_name reviwer.rname%type;
CURSOR c1 IS
SELECT r.rname INTO Reviewer_name FROM reviwer r INNER JOIN paper_review pr ON r.rid=pr.rid
WHERE r.raffiliation NOT IN (SELECT a.aaffiliation FROM author a INNER JOIN paper p ON a.aid=p.corr_aid WHERE p.pid=id and a.aaffiliation in ('UMBC','UMD'));
BEGIN
open c1;
LOOP
IF c1%NOTFOUND
THEN
IF c1%ROWCOUNT=0
THEN
DBMS_OUTPUT.PUT_LINE('NO records found,input paper ID is invalid');
END IF;
EXIT;
ELSE
FETCH c1 INTO Reviewer_name;
EXIT WHEN c1%NOTFOUND;
DBMS_OUTPUT.PUT_LINE(Reviewer_name);
END IF;
end loop;
close c1;
end;
--- Paper Review drop table paper_review cascade constraint; drop table paper_author cascade constraint; drop table paper...
Suppose a student is taking IS 620 section 1 and HCC 629 section 1 for spring 2019. Use an explicit cursor to print out the titles and prices of textbooks for these two courses. Sample code to create the tables: drop table textbook_schedule cascade constraints; drop table textbook_author cascade constraints; drop table schedule cascade constraints; drop table course cascade constraints; drop table textbook cascade constraints; drop table author cascade constraints; drop table teacher cascade constraints; drop table program cascade constraints;...
Use the SQL statements provided to create your tables. Write one SQL statement for each of the following problems. You can only use the conditions listed in the tasks. E.g., in task 1, you cannot manually look up pid of Information Systems undergraduate program. Here is the given code: drop table textbook_schedule cascade constraints; drop table textbook_author cascade constraints; drop table schedule cascade constraints; drop table course cascade constraints; drop table textbook cascade constraints; drop table author cascade constraints; drop...
-- drop tables DROP TABLE REQUEST CASCADE CONSTRAINTS; DROP TABLE FULLORDER CASCADE CONSTRAINTS; DROP TABLE PRODUCT CASCADE CONSTRAINTS; DROP TABLE CUSTOMER CASCADE CONSTRAINTS; -- create and link tables CREATE TABLE CUSTOMER ( CustomerID INTEGER, Name VARCHAR2(40), City VARCHAR2(20), State CHAR(2), Zip CHAR(5), CONSTRAINT PK_CUSTOMER PRIMARY KEY (CustomerID) ); CREATE TABLE PRODUCT ( ProductID INTEGER, Description VARCHAR2(30), Material VARCHAR2(20), Price NUMBER(5,2), CONSTRAINT PK_PRODUCT...
-- drop tables DROP TABLE REQUEST CASCADE CONSTRAINTS; DROP TABLE FULLORDER CASCADE CONSTRAINTS; DROP TABLE PRODUCT CASCADE CONSTRAINTS; DROP TABLE CUSTOMER CASCADE CONSTRAINTS; -- create and link tables CREATE TABLE CUSTOMER ( CustomerID INTEGER, Name VARCHAR2(40), City VARCHAR2(20), State CHAR(2), Zip CHAR(5), CONSTRAINT PK_CUSTOMER PRIMARY KEY (CustomerID) ); CREATE TABLE PRODUCT ( ProductID INTEGER, Description VARCHAR2(30), Material VARCHAR2(20), Price NUMBER(5,2), CONSTRAINT PK_PRODUCT...
drop table department cascade constraints; create table department ( Dname varchar2(15) not null, Dnumber int not null, Mgr_ssn char(9) not null, mgr_start_date Date, primary key (Dnumber), Unique (Dname)); insert into DEPARTMENT values ('Research', '5', '333445555', '22-May-1988'); insert into DEPARTMENT values ('Administration', '4', '987654321', '01-Jan-1995'); insert into DEPARTMENT values ('Headquarters', '1', '888665555', '19-Jun-1981'); drop table employee cascade constraints; create table employee ( Fname varchar2(15) not null, Minit char(1), Lname varchar2(15) not null, Ssn char(9), Bdate date, Address varchar2(30), Sex char(1),...
I am trying to delete these tables from my data base and I keep getting: "mysql> DROP TABLE Courses; ERROR 1217 (23000): Cannot delete or update a parent row: a foreign key constraint fails" I am using the command DROP TABLE Courses; Below is my sql file use sdev300; // Create a student table CREATE TABLE Students ( PSUsername varchar(30) primary key, FirstName varchar(30), LastName varchar(30), EMail varchar(60) ); CREATE TABLE Courses( CourseID int primary key, CourseDisc varchar(4), CourseNum varchar(4),...
Question: Write one SQL statement for the following question: Return number of players whose rating is over 1000. Background information: This is a chess tournament management database that stores information about chess players, tournaments, sections, registrations, and pairings. Each player has an ID, name, grade (0 to 12) and rating. Each tournament has a number of sections. Each player can register for a section of a tournament In each round of a tournament, players in the same section will be...
Using SQL and the following info Question 3: Find the people who do not have Viper Certification but are still assigned to Viper class ship Find the fname, lname, and ship_instance_id for all people who do not have Viper certification but are assigned to at least one instance of a Viper class ship (this includes all variants of Viper class ships). Return a row for every ship/person combination. Order your results by fname in ascending order. Use the BSG database...
Using SQL and the following info Question 3: Find the people who do not have Viper Certification but are still assigned to Viper class ship Find the fname, lname, and ship_instance_id for all people who do not have Viper certification but are assigned to at least one instance of a Viper class ship (this includes all variants of Viper class ships). Return a row for every ship/person combination. Order your results by fname in ascending order. Use the BSG database...
Database concepts Find the names and ids of the students who have taken at most one course in the Spring 2010 semester. Notice, at most one means one or zero. So, the answer should include students who did not take any course during that semester The data: create table classroom (building varchar(15), room_number varchar(7), capacity numeric(4,0), primary key (building, room_number) ); create table department (dept_name varchar(20), building varchar(15), budget numeric(12,2) check (budget > 0), primary key (dept_name) ); create...