Question

In: Computer Science

The schema for the Academics database is as follows. Understanding this schema is necessary to answer...

The schema for the Academics database is as follows. Understanding this schema is necessary to answer the questions in Part B.

DEPARTMENT(deptnum, descrip, instname, deptname, state, postcode) 
ACADEMIC(acnum, deptnum*, famname, givename, initials, title) 
PAPER(panum, title) 
AUTHOR(panum*, acnum*) 
FIELD(fieldnum, id, title) 
INTEREST(fieldnum*, acnum*, descrip) 

The semantics of most attributes are self-explanatory. For each relation, the primary key is underlined and any foreign keys are denoted by an asterisk (*). Some additional information for relations is given below:

  • DEPARTMENT: Each academic department (deptnum) belongs to an institution (instname).  
  • ACADEMIC: Each academic (acnum) belongs to one department (deptnum).  
  • AUTHOR: A paper (panum) may be written by more than one academic (acnum).  
  • FIELD: The relation describes research areas, where id is a classification code like B.1.1.  
  • INTEREST: The relation describes that an academic may have research interests in several fields (fieldnum), and provide description (descrip) of his/her research.

Question1 SQL

calculate the number of academics that have more than 10 papers?

Question 2 SQL

find the departments where at most 10 academics have more than 2 research fields, and display in alphabetical order the names of institutions and names of departments?

Solutions

Expert Solution

Schema of table:-

CREATE TABLE DEPARTMENT(deptnum int primary key, descrip text, instname varchar(30), deptname varchar(20), state varchar(15), postcode number);

CREATE TABLE ACADEMIC(acnum int primary key, deptnum int not null, famname varchar(15), givename varchar(15), initials text, title varchar(15),FOREIGN KEY (deptnum) REFERENCES DEPARTMENT(deptnum));

CREATE TABLE PAPER(panum int primary key , title varchar(15));


CREATE TABLE AUTHOR(panum int not null, acnum int not null,FOREIGN KEY (panum) REFERENCES PAPER(panum),FOREIGN KEY (acnum) REFERENCES ACADEMIC(acnum));


CREATE TABLE FIELD(fieldnum int primary key, id int not null, title text);

CREATE TABLE INTEREST(fieldnum int not null, acnum int not null, descrip text,FOREIGN KEY (fieldnum) REFERENCES FIELD(fieldnum),FOREIGN KEY (acnum) REFERENCES ACADEMIC(acnum));

Insert sample value as we required to show sample output:-

insert into ACADEMIC values(101,8,null,null,null,null);
insert into AUTHOR values(11,101);

insert into INTEREST values(5,101,null);
insert into DEPARTMENT values(8,null,"IIT","Chemical",null,null);

Question1:- calculate the number of academics that have more than 10 papers?

Answer: - select * from ACADEMIC as A,AUTHOR as B where A.acnum==B.acnum and panum>10;

Question2: - find the departments where at most 10 academics have more than 2 research fields, and display in alphabetical order the names of institutions and names of departments?

Answer: - select instname,deptname,fieldnum from DEPARTMENT as D,ACADEMIC as A,INTEREST as I where D.deptnum==A.deptnum and A.acnum==I.acnum and fieldnum>2 order by instname asc limit 10;


Related Solutions

For the given database schema. Answer the following questions. Company Database customer(cust_id, name, address) product(product_id, product_name,...
For the given database schema. Answer the following questions. Company Database customer(cust_id, name, address) product(product_id, product_name, price, quantity) transaction(trans_id, cust_id, time_date) product_trans(product_id, trans_id) Identify the primary keys and foreign keys for the relations and specify at least two different types of integrity constraints that would be applicable for different relations given.
When is the conceptual schema of a database changed?- if we update data in the database...
When is the conceptual schema of a database changed?- if we update data in the database -if we alter the logical structure of the database -if we retrieve data from the database -if we alter the storage structure of the database Which of the following has the same meaning as the outer union? Group of answer choices -the left outer (natural) join -the right outer (natural) join -the full outer (natural) join -the inner (natural) join Assume {A, B} is...
Given the same simple Employee-Workson-Project database schema , which contains three files described as follows:
Given the same simple Employee-Workson-Project database schema , which contains three files described as follows:Emp (eid : integer, ename : string, age : integer, salary: real)Workson (eid : integer, pid : integer, hours : integer)Project (pid : integer, pname : string, budget : real, managerid : integer)Note : eid, ename, age and salary are the employee id, name, age and salary respectively. Also, hours is the number of hours worked by employee on a project. The rest of the attributes...
• Relational Schema Create a relational database schema consisting of the four relation schemas representing various...
• Relational Schema Create a relational database schema consisting of the four relation schemas representing various entities recorded by a furniture company.   Write CREATE TABLE statements for the following four relation schemas. Define all necessary attributes, domains, and primary and foreign keys. Customer(CustomerID, Name, Address) FullOrder(OrderID, OrderDate, CustomerID) Request(OrderID, ProductID, Quantity) Product(ProductID, Description, Finish, Price) You should assume the following: Each CustomerID is a number with at most three digits, each OrderID is a number with at most five digits,...
Write a javascript code to check if the JSON body follows the schema. schema is {...
Write a javascript code to check if the JSON body follows the schema. schema is {     "name":"john doe",     "mood":"happy"     "major":"cs",     "date":"2024" } json body is {     "name":"john doe", "height":"170cm"     "major":"cs",     "date":"2024" } the result should be false
This refer to the “om” database (or Schema) that you will find in your MySQL Workbench...
This refer to the “om” database (or Schema) that you will find in your MySQL Workbench program if you have run the sample database install script. Please save all of your answers in one script (.sql) or type all your answers into Notepad++ and submit them as a single .sql file. Please test your SQL statements in Workbench 1.       Using an INNER JOIN, select the order_id, order_date, shipped_date, fname, and customer_phone from the orders and customers tables. The fname is a...
Discuss the three-schema architecture and its benefits for database development and design.
Discuss the three-schema architecture and its benefits for database development and design.
All questions in this assignment refer to the “om” database (or Schema) that you will find...
All questions in this assignment refer to the “om” database (or Schema) that you will find in your MySQL Workbench program if you have run the sample database install script. Please save all of your answers in one script (.sql) or type all your answers into Notepad++ and submit them as a single .sql file. You are encouraged to test your SQL statements in Workbench, and please use the ‘tidy’ tool to properly format your SQL before you save it...
Answer the questions in detail: 1. What tasks are necessary to keep a database functional? 2....
Answer the questions in detail: 1. What tasks are necessary to keep a database functional? 2. How do you schedule backups to safeguard data? How do you know/differentiate  what data should be and what data needs to be backed up? 3. What can you do to keep a database working efficiently? What does it mean to have an efficient database?
This assignment refer to the “om” database (or Schema).      1.Write an INSERT statement that adds this...
This assignment refer to the “om” database (or Schema).      1.Write an INSERT statement that adds this row to the Items table:   a.       Artist:               Newly Added b.       Title:                      Assignment 3 c.        unit_price:         0.0 d.       ID:                          12 2.       Write an UPDATE statement that modifies the row you just added to the Items table. This statement should change the artist column to “RockOn”, and it should use the ID column to identify the row.    3.       Write a DELETE statement that deletes the row you...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT