assignment1_sol
.sql
keyboard_arrow_up
School
Indiana University, Bloomington *
*We aren’t endorsed by this school
Course
561
Subject
Computer Science
Date
Apr 3, 2024
Type
sql
Pages
5
Uploaded by ColonelWorld13096
/*
Assignment 1 will examine your knowledge about SQL using
a subset of the UMLS dataset
Please note that you can only use what we covered so far
by the time this assigment is released.
For example, aggregation is not allowed (e.g., group by)
Please answer every block marked with "## Please ..."
Each mistake deducts 5 points from a total of 100 points
If more than 100 points are deducted, you will get 0 still
*/
------ PART I: Single-Table Queries ------
-- Q1: Check 100 tuples in the "mrrel" table -- Requirement: Please self-study https://www.w3schools.com/sql/sql_top.asp
-- You can use "limit n" to check a few tuples in a table to get familiar with its data and schema
-- This is helpful when you formulate queries below
select * from mrrel limit 100;
-- Q2: Find the CUIs of concepts that have synonyms (i.e., more than 1 AUI)
-- Hint: there are 592,039 results like "C0000005", "C0000039", "C0000052"
select distinct con1.cui from mrconso con1, mrconso con2
where con1.cui = con2.cui and con1.aui <> con2.aui;
-- Q3: Find the CUIs of concepts that only have one 1 AUI, create it as a materialized view "mrconso_ oneAUI"
-- Hint: there are 178,595 results like "C0000266", "C0000353", "C0000666"
create materialized view mrconso_oneAUI as (
(select distinct cui from mrconso)
except
(select distinct con1.cui from mrconso con1, mrconso con2
where con1.cui = con2.cui and con1.aui <> con2.aui)
);
-- Q4: With the help of view "mrconso_oneAUI" above, recover their complete tuples,
order by CUI
-- Requirement: Use NATRUAL JOIN !!!
select * from mrconso_oneAUI natural join mrconso order by cui;
-- Q5: With the help of view "mrconso_oneAUI" above, recover their complete tuples,
order by CUI
-- Requirement: Use SET PREDICATE !!!
select * from mrconso where cui in (select * from mrconso_oneAUI) order by cui;
-- Q6: Find cui, aui, tty, str of all concepts whose string field (str) contains the word "tooth" and is from source (sab) "MSH", order by CUI
-- Requirement: Please self-study string matching in SQL from https://www.w3schools.com/sql/sql_like.asp
-- Hint: there are 19 results
select cui, aui, tty, str from mrconso where str like '%tooth%' and sab='MSH' order
by cui;
-- Q7: Find all different possible values of (rel, rela) pairs for source (sab) "MSH"
-- Requirement: Look up "REL Description" in https://www.nlm.nih.gov/research/umls/knowledge_sources/metathesaurus/release/
abbreviations.html
-- Hint: there are 22 results
select distinct rel, rela from mrrel where sab = 'MSH';
-- Q8: Find all different possible values of (rel, rela, sab) triples where source (sab) is not "MSH"
-- Hint: there are 244 results
select distinct rel, rela, sab from mrrel where sab <> 'MSH';
-- Q9: Find the common (rel, rela) pairs shared by both sources "MSH" and "SNOMEDCT_US"
-- Hint: use set operation; the result is empty
(select distinct rel, rela from mrrel where sab = 'MSH')
intersect
(select distinct rel, rela from mrrel where sab = 'SNOMEDCT_US');
-- Q10: Find the common "rela" shared by both sources "MSH" and "SNOMEDCT_US"
-- Hint: use set operation; there are 2 results
(select distinct rela from mrrel where sab = 'MSH')
intersect
(select distinct rela from mrrel where sab = 'SNOMEDCT_US');
-- Q11: Find all the possible (tui, sty) values
-- Hint: check table "mrsty"; there are 127 results
select distinct tui, sty from mrsty;
------ PART II: Multi-Table Queries ------
-- Q12: Find (cui, aui, sab, str) of all those concepts under semantic type T018 ("Embryonic Structure")
-- Hint: there are 3235 results
select mrconso.cui, aui, sab, str from mrconso, mrsty where mrconso.cui = mrsty.cui
and tui = 'T018';
-- Q13: Find all those relations of "Alzheimer's disease" and its synonyms
-- Hint: in SQL, to include a single quote character within a string literal, you need to escape it by using two consecutive single quotes.
-- Hint: there are 264 results
---- Step 1: Finds all CUIs with str = "Alzheimer's disease", and see what are the CUIs?
select * from mrconso where str = 'Alzheimer''s disease';
---- Step 2: Find all synonyms of the CUIs above, return (aui, str, sab) only
select aui, str, sab from mrconso where cui = 'C0002395';
---- Step 3: Find all relations in mrrel where an end-concept is Alzheimer's disease, name it as a view "rel_AD"
select * from mrrel where cui1 = 'C0002395' or cui2 = 'C0002395';
-- Q14: The relations above only has IDs like cui and aui. Please create a new version of this table listing (aui1, str1, rela, aui2, str2, sab)
---- Step 1: create a view recording Python-dict-style mapping: aui_str[aui] = str
drop materialized view if exists aui_str;
create materialized view aui_str as
select aui, str from mrconso;
---- Step 2: use it to convert the result table of Q14, return tuples with format (aui1, str1, rela, aui2, str2, sab)
---- Hint: self-join on mrconso is needed since we have (aui1, aui2)
select aui1, r1.str as str1, rela, aui2, r2.str as str2, sab from mrrel, aui_str r1, aui_str r2 where r1.aui = aui1 and r2.aui = aui2 and (cui1 = 'C0002395' or cui2 = 'C0002395');
---- Step 3:
---- UMLS is actually a knowledge graph better modeled as an RDF database rather than a relational database.
---- An RDF database stores S-P-O (Subject-Predicate-Object) relations as in our mrrel table, but is more graph-query friendly.
---- However, only MeSH is currently supported with SPARQL API: https://id.nlm.nih.gov/mesh/
---- We are basically using SQL to solve graph queries, which takes quite some joins.
---- Now, check the results from Step 2, such as
---- "Alzheimer's disease"
"isa"
"A27169206"
"Alzheimer's disease co-occurrent with delirium"
"SNOMEDCT_US"
---- Answer the question: is aui1 the subject or the object? is aui2 the subject or
the object?
---- Hint: getting your understanding of the relation edge direction correct is important for the later queries to complete.
---- ################################################################
---- ## Your Answer: aui 1 is the object, and aui 2 is the subject
---- ################################################################
-- Q15. find the overlapped relations (aui, paui) between mrrel and mrhier, return tuples of the form (cui, aui, paui, str, pstr)
-- Hint: paui is parent-aui based on "isa" relationship, it is important to have a correct understanding of edge direction in Step 3 of Q15 above
-- Hint: str can be obtained from the materialized view "aui_str", pstr is parent-
str to be created for result relation
-- Hint: there are 602431 results
with pa_intersect as (
(select cui, aui, paui from mrhier)
intersect
(select cui2, aui2, aui1 from mrrel)
)
select pa_intersect.cui, pa_intersect.aui, r.str as str, paui, rp.str as pstr from pa_intersect, aui_str r, aui_str rp where r.aui = pa_intersect.aui and rp.aui = paui;
-- Q16. [Recursive View]
-- We consider only the hierarchy defined by the "isa" relationship
-- Find all concepts BELOW "Alzheimer's disease" and one level above "Alzheimer's disease" (i.e., its parents), return tuples of the form (aui, paui, str, pstr)
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
Related Questions
Write a PL/SQL block that uses a searched case statement to classify students based on their scores in a certain test according to
the following table.
Score Action
90
80-89 A certificate is given
70-79 A training course is recommended
<70
A scholarship is given
The course should be repeatcd
NB: Write the searched CASE structure only.
Use the editor to format your answer
arrow_forward
PL/SQL Question
I need to build pl/sql block that prompts a user for the number of visitors each day for the past 5 days and then displays the average number of visitors per day.
For example;
day 1: 19
day 2: 21
day 3: 23
...
The avg number of visitors is: ___
like this.
arrow_forward
Q2:
Design Database for the following scenario and Write SQL queries.
Create an ERD for the following scenario. Suppose there is a grocery store near your house. Following can be
considered for ERD:
A grocery store may have more than one employee.
A grocery store has exactly one manager.
The manager has one or more sales men working under him.
Grocery store has more than one portion for the products.
• Each product has a barcode, name, expired date.
Many customers can busy many products, but each product is bought by only one customer.
Each customer will get an invoice for his /her purchase.
The bill invoice has an id.
arrow_forward
SQL Database
Write PL/SQL or T-SQL procedures to accomplish the following tasks:
Obtain the first name and last name, separated by a space, of the guide whose number currently is stored in I_GUIDE_NUM. Place these values in the variables I_FIRST_NAME and I_LAST_NAME. Output the contents of I_GUIDE_NUM, I_FIRST_NAME, and I_ LAST_NAME.
Obtain the number of persons, customer number, and customer last name for every reservation whose ID currently is stored in I_RESERVATION_ID. Place these values in the variables I_NUM_PERSONS, I_CUSTOMER_NUM, and I_LAST_NAME, respectively. Output the contents of I_NUM_PERSONS, I_CUSTOMER_NUM, and I_LAST_NAME.
Add a row to the GUIDE table.
Change the last name of the guide whose number is stored in I_GUIDE_NUM to the value currently found in I_LAST_NAME.
Delete the guide whose number is stored in I_GUIDE_NUM
arrow_forward
Computer Science
This question is related to pl/SQL:-
Using a Cursor in a Package
In this assignment, you work with the sales tax computation because the Brewbean's lead
programmer expects the rates and states applying the tax to undergo some changes. The tax
rates are currently stored in packaged variables but need to be more dynamic to handle the
expected changes. The lead programmer has asked you to develop a package that holds the
tax rates by state in a packaged cursor. The BB TAX table is updated as needed to reflect
which states are applying sales tax and at what rates. This package should contain a function
that can receive a two-character state abbreviation (the shopper's state) as an argument, and it
must be able to find a match in the cursor and return the correct tax rate. Use an anonymous
block to test the function with the state value NC.
arrow_forward
Write a PL/SQL Function that accepts 4 integers, 2 representing the homeTeamID and visitorTeamID, and the other 2 representing the score for each team during a game : htscore and vtscore
The function will determine which team won the match and return the teamID of the winning team. You can achive this by comparing htscore > or < then vtscore.. if htscore is bigger then return hteamID or else return vteamID.
If the game was a tie (the 2 scores are the same value) return a 0.
arrow_forward
Assignment : PL/SQL Practice
Note: PL/SQL can be executed in SQL*Plus or SQL Developer or Oracle Live SQL.
Write an anonymous PL/SQL block that will update the salary of all doctors in the Pediatrics area by 1000 (Note: Current salary + 1000). Verify that the salary has been updated by issuing a select * from doctor where area = ‘Pediatrics’. You may have to run the select statement twice to check the data before and after the update.
arrow_forward
relation:
Book (BookID, Author, ISBN, Title)
Write a PL/SQL block of code that performs the following tasks:
Read a Book id provided by user at run time and store it in a variable.
Fetch the Author and title of the book having the entered id and store them inside two variables
Display the fetched book author and title.
arrow_forward
help me SQl
arrow_forward
Write the appropriate SQL query for each of the following questions:
1) Display details of ALL the clubs running by the college
2) Display the details of the IT club (IT is the name of the club)
arrow_forward
sql queries
Employees(EMPLOYEE_ID, FIRST_NAME, LAST_NAME, EMAIL, PHONE_NUMBER, HIRE_DATE,JOB_ID, SALARY, COMMISSION_PCT, MANAGER_ID, DEPARTMENT_ID,DEPARTMENT_NAME)Department(DEPARTMENT_ID, DEPARTMENT_NAME, MANAGER_ID, LOCATION_ID)Location(LOCATION_ID,STREET_ADDRESS,POSTAL_CODE,CITY,STATE_PROVINCE,COUNTRY_ID)
Write a query in SQL to display the Entire data of All those employees whoseDEPARTMENT_ID is greater than the DEPARTMENT_ID of all those employees who earn morethan 50,000 per month
Write a query in SQL to display the minimum, maximum salary and DEPARTMENT_NAMEof all those departments whose minimum salary is greater than 4000 in ascending order.
arrow_forward
SQL QUERIES
Employees(EMPLOYEE_ID, FIRST_NAME, LAST_NAME, EMAIL, PHONE_NUMBER, HIRE_DATE,JOB_ID, SALARY, COMMISSION_PCT, MANAGER_ID, DEPARTMENT_ID,DEPARTMENT_NAME)Department(DEPARTMENT_ID, DEPARTMENT_NAME, MANAGER_ID, LOCATION_ID)Location(LOCATION_ID,STREET_ADDRESS,POSTAL_CODE,CITY,STATE_PROVINCE,COUNTRY_ID)
Write a query in SQL to display the DEPARTMENT_NAME of all those Departments whoseDEPARTMENT_ID is greater than the DEPARTMENT_ID of Physics department.
Write a Query in SQL to show the FIRST_NAME of all those employees whose salary is lessthan the salary of all those employees whose MANAGER_ID is 101 or 102.
arrow_forward
SBN Title Author 12345678 The Hobbit J.R.R. Tolkien 45678912 DaVinci Code Dan Brown Your student ID DBS311 Your Name
use the following statement to Write a PL/SQL Function that accepts 4 parameters, 2 strings representing students names, and 2 integers representing the marks they received in DBS311. The function will determine which student had the higher mark and return the name of the student. If the marks were the same, then return the word "same" and return "error" if an error occurs or the calculation can not be determined.
arrow_forward
Write the appropriate SQL query for each of the following questions:
A) Display ALL the activities organized by the IT club
B) Display the number of students who are acting in each club.
arrow_forward
INFO 2303 Database Programming
Assignment : PL/SQL Practice
Note: PL/SQL can be executed in SQL*Plus or SQL Developer or Oracle Live SQL.
Write an anonymous PL/SQL block that will delete all patients for doctors that works in the Family Practice Verify that patients have been deleted accordingly. Then do a select * from patients where doc_id = (select doc_id from doctor where area = ‘Family Practice’. You should get no rows.
arrow_forward
Create a PL/SQL database programming block with
DECLARE
BEGIN
END;
In Declare section define a local scalar (simple) variables. lv_deptno NUMBER
And assign initial values as 10
lv_deptno NUMBER := 50;
In Declare section again, define a cursor and select last_name, salary and manager_id of employees the ones who are working in the department defined in a)
In this example department will be lv_deptno:=50;
Sample code:
Cursor c_emp as
SELECT last_name, salary, manager_id FROM employees
WHERE department_id = lv_deptno;
In the execution section (BEGIN and END)
Create CURSOR FOR LOOP for cursor to process
In this cursor loop, your code has to check salary and also manager_id numbers each time new records being fetched. And based on these conditions either employee gets raise or not get raise.
If employee salary is less than 5000 and also if employees managers is either 101 or 124 then it means employee is due for raise otherwise employee is not due for raise
Sample…
arrow_forward
INFO 2303 Database Programming
Assignment : PL/SQL Practice
Note: PL/SQL can be executed in SQL*Plus or SQL Developer or Oracle Live SQL.
Question:
Write an anonymous PL/SQL block that will delete all patients for doctors that works in the Family Practice Verify that patients have been deleted accordingly. Then do a select * from patients where doc_id = (select doc_id from doctor where area = ‘Family Practice’. You should get no rows.
Patietn table:
CREATE TABLE PATIENT(PT_ID NUMBER(3),PT_LNAME VARCHAR2(15),PT_FNAME VARCHAR2(15),PTDOB DATE,DOC_ID NUMBER(3),NEXTAPPTDATE DATE,LASTAPPTDATE DATE,CONSTRAINT PATIENT_PT_ID_PK PRIMARY KEY (PT_ID),CONSTRAINT PATIENT_DOC_ID_FK FOREIGN KEY(DOC_ID)REFERENCES DOCTOR);
INSERT INTO patient VALUES(168, 'James', 'Paul', TO_DATE('14-MAR-97'), 432, TO_DATE('01-JUL-03'), TO_DATE('01-JUN-03'));INSERT INTO patient VALUES(331, 'Anderson', 'Brian', TO_DATE('06-MAR-48'), 235,TO_DATE('01-JUL-03'), TO_DATE('01-JUN-03'));INSERT INTO patient…
arrow_forward
Write the appropriate SQL query for each of the following questions:
Display the number of students acting in ‘Radio Club’
Display the sum of fees of activities organized by the IT club
arrow_forward
Write the appropriate SQL query for each of the following questions:
Display the number of students acting in ‘Radio Club’
Display the sum of fees of activities organized by the IT club
arrow_forward
A better design would be one with the following tables:
Patient : | pid | name | dob | addr | tel |
Exam : | acc | pid | eid | result | date |
ExamDictionary : | eid | name | normal |
Questions:
Create SQL queries (select statements) that accomplish the following.
1. List all of the Exams for Ms. Jones (pid=12).
2. List all of the Patients that hail from jolly old London.
3. List all of the Exams with results that exceed their normal.
4. List the name of all Patients that had Exams with results that exceed their (the exam’s) normal.
5. List the name of all Patients that had Exams with results that exceed their (the exam’s) normal, but list names only once and in alphabetical order.
arrow_forward
Using the Online SQL Editor, answer the following questions with screenshots.
Link: https://www.programiz.com/sql/online-compiler/
1) Show the columns item and amount from Orders table which starts with the letter “M” but doesn’t end with the letter “r”;
2) Show the first name and last name columns from the Customers table which either starts with the letter “J” or ends with the letter “e”. Answer(screenshot of code & output from SQL Editor)
arrow_forward
In SQL
This sample database consists of the following tables(see image for tables and there is one more at the bottom in this text):• Customers: stores customer’s data• Products: stores a list of scale model cars• ProductLines: stores a list of product line categories• Orders: stores sales orders placed by customers• OrderDetails: stores sales order line items for each sales order• Payments: stores payments made by customers based on their accounts• Employees: stores all employee information as well as the organization structuresuch as who reports to whom• Offices: stores sales office data
Write SQL code for the following:We want to add a new sale order for the customer (customerNumber = 145) in thedatabase. The steps of adding a sale order are described as follows:(1) Get latest sale order number from “orders” table, and use the next sale ordernumber as the new sale order number(2) Insert a new sale order into “orders” table for the customer (customerNumber =145). For this order, the…
arrow_forward
SQL Language Question
arrow_forward
In SQL
This sample database consists of the following tables(see image for tables and there is one more at the bottom in this text):• Customers: stores customer’s data• Products: stores a list of scale model cars• ProductLines: stores a list of product line categories• Orders: stores sales orders placed by customers• OrderDetails: stores sales order line items for each sales order• Payments: stores payments made by customers based on their accounts• Employees: stores all employee information as well as the organization structuresuch as who reports to whom• Offices: stores sales office data
Write SQL code for the following:We want to add a new sale order for the customer (customerNumber = 145) in thedatabase. The steps of adding a sale order are described as follows:(1) Get latest sale order number from “orders” table, and use the next sale ordernumber as the new sale order number(2) Insert a new sale order into “orders” table for the customer (customerNumber =145). For this order, the…
arrow_forward
SQL:
Create a SQL query that uses an uncorrelated subquery and no joins to display the descriptions for products provided by a vendor in area code 615. Remember, the main difference between a correlated subquery and uncorrelated subquery is that, in a correlated subquery, the inner query is dependent upon the outer query, while, with an uncorrelated query, the inner query does not depend upon the outer query. Instead, it runs just once. You should NOT use union, minus, or intersect in this query. The outer query will use the PRODUCT table and the inner query will use the VENDOR table [hint: you should have 9 records of output].
My code:
select p_descript from product where (select v_areacode from vendor where v_areacode = '615' ;
I am getting this error, problem is I can't see what is missing any assistance is appreciated.
ORA-00936: missing expression
arrow_forward
Given the following relation:
Book (BookID, Author, ISBN, Title)
Write a PL/SQL block of code that performs the following tasks:
Read a Book id provided by user at run time and store it in a variable.
Fetch the Author and title of the book having the entered id and store them inside two variables
Display the fetched book author and title.
arrow_forward
SQL
A programmer wrote code with the underlying SQL to check if a user can access / log into a system.
SELECT *
FROM users
WHERE login = ‘ replaced by the input login ‘
AND password = ‘ replaced by the input password ‘
What is the query if login is ‘OR true -- and password is Hello? Write the query.
What does the query above return?
What is the name of this security issue?
arrow_forward
Develop a PL/SQL block that would go through all the employees from EMPLOYEES table who work in department_id= 90 (there is suppose to be 3 employee who work in Department 90)
IN BEGIN END END SECTION;
Execute 3 separate of SELECT statement one after the other. Each SELECT will pull first_name , salary of each employee and store them in local variables.
SELECT LOAD INTO v_firstname1, v_salary1 WHERE employee_id=100
Then second
SELECT first_name, salary INTO v_firstname2, v_salary2 ….. WHERE employee_id=101
Then third
SELECT, SELECT first_name, salary INTO v_firstname3, v_salary3 ….. WHERE employee_id=102
You must now have 6 local variables. DECLARE all of them accordingly in DECLARE section and use them in BEGIN and END.
Then add another SELECT statement in BEGIN-END to find company average salary
SELECT avg(salary) INTO v_avgsal FROM EMPLOYEES;
!!! Do not forget to create v_avgsal local variable in DECLARE section.
arrow_forward
Writes a PL/SQL function that calculates the factorial of a number passed as a parameter.
The Factorial of a number n is defined as −0! = 1n! = n*(n-1)*(n-2)*(n-3)... 1 for n > 0
arrow_forward
: Write SQL queries DDL Queries to implement the following Relational Model i.e. create the Nurse and Care_Center relations (including primary key and foreign key). Intelligently write data types. Show Output.
arrow_forward
SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Related Questions
- Write a PL/SQL block that uses a searched case statement to classify students based on their scores in a certain test according to the following table. Score Action 90 80-89 A certificate is given 70-79 A training course is recommended <70 A scholarship is given The course should be repeatcd NB: Write the searched CASE structure only. Use the editor to format your answerarrow_forwardPL/SQL Question I need to build pl/sql block that prompts a user for the number of visitors each day for the past 5 days and then displays the average number of visitors per day. For example; day 1: 19 day 2: 21 day 3: 23 ... The avg number of visitors is: ___ like this.arrow_forwardQ2: Design Database for the following scenario and Write SQL queries. Create an ERD for the following scenario. Suppose there is a grocery store near your house. Following can be considered for ERD: A grocery store may have more than one employee. A grocery store has exactly one manager. The manager has one or more sales men working under him. Grocery store has more than one portion for the products. • Each product has a barcode, name, expired date. Many customers can busy many products, but each product is bought by only one customer. Each customer will get an invoice for his /her purchase. The bill invoice has an id.arrow_forward
- SQL Database Write PL/SQL or T-SQL procedures to accomplish the following tasks: Obtain the first name and last name, separated by a space, of the guide whose number currently is stored in I_GUIDE_NUM. Place these values in the variables I_FIRST_NAME and I_LAST_NAME. Output the contents of I_GUIDE_NUM, I_FIRST_NAME, and I_ LAST_NAME. Obtain the number of persons, customer number, and customer last name for every reservation whose ID currently is stored in I_RESERVATION_ID. Place these values in the variables I_NUM_PERSONS, I_CUSTOMER_NUM, and I_LAST_NAME, respectively. Output the contents of I_NUM_PERSONS, I_CUSTOMER_NUM, and I_LAST_NAME. Add a row to the GUIDE table. Change the last name of the guide whose number is stored in I_GUIDE_NUM to the value currently found in I_LAST_NAME. Delete the guide whose number is stored in I_GUIDE_NUMarrow_forwardComputer Science This question is related to pl/SQL:- Using a Cursor in a Package In this assignment, you work with the sales tax computation because the Brewbean's lead programmer expects the rates and states applying the tax to undergo some changes. The tax rates are currently stored in packaged variables but need to be more dynamic to handle the expected changes. The lead programmer has asked you to develop a package that holds the tax rates by state in a packaged cursor. The BB TAX table is updated as needed to reflect which states are applying sales tax and at what rates. This package should contain a function that can receive a two-character state abbreviation (the shopper's state) as an argument, and it must be able to find a match in the cursor and return the correct tax rate. Use an anonymous block to test the function with the state value NC.arrow_forwardWrite a PL/SQL Function that accepts 4 integers, 2 representing the homeTeamID and visitorTeamID, and the other 2 representing the score for each team during a game : htscore and vtscore The function will determine which team won the match and return the teamID of the winning team. You can achive this by comparing htscore > or < then vtscore.. if htscore is bigger then return hteamID or else return vteamID. If the game was a tie (the 2 scores are the same value) return a 0.arrow_forward
- Assignment : PL/SQL Practice Note: PL/SQL can be executed in SQL*Plus or SQL Developer or Oracle Live SQL. Write an anonymous PL/SQL block that will update the salary of all doctors in the Pediatrics area by 1000 (Note: Current salary + 1000). Verify that the salary has been updated by issuing a select * from doctor where area = ‘Pediatrics’. You may have to run the select statement twice to check the data before and after the update.arrow_forwardrelation: Book (BookID, Author, ISBN, Title) Write a PL/SQL block of code that performs the following tasks: Read a Book id provided by user at run time and store it in a variable. Fetch the Author and title of the book having the entered id and store them inside two variables Display the fetched book author and title.arrow_forwardhelp me SQlarrow_forward
- Write the appropriate SQL query for each of the following questions: 1) Display details of ALL the clubs running by the college 2) Display the details of the IT club (IT is the name of the club)arrow_forwardsql queries Employees(EMPLOYEE_ID, FIRST_NAME, LAST_NAME, EMAIL, PHONE_NUMBER, HIRE_DATE,JOB_ID, SALARY, COMMISSION_PCT, MANAGER_ID, DEPARTMENT_ID,DEPARTMENT_NAME)Department(DEPARTMENT_ID, DEPARTMENT_NAME, MANAGER_ID, LOCATION_ID)Location(LOCATION_ID,STREET_ADDRESS,POSTAL_CODE,CITY,STATE_PROVINCE,COUNTRY_ID) Write a query in SQL to display the Entire data of All those employees whoseDEPARTMENT_ID is greater than the DEPARTMENT_ID of all those employees who earn morethan 50,000 per month Write a query in SQL to display the minimum, maximum salary and DEPARTMENT_NAMEof all those departments whose minimum salary is greater than 4000 in ascending order.arrow_forwardSQL QUERIES Employees(EMPLOYEE_ID, FIRST_NAME, LAST_NAME, EMAIL, PHONE_NUMBER, HIRE_DATE,JOB_ID, SALARY, COMMISSION_PCT, MANAGER_ID, DEPARTMENT_ID,DEPARTMENT_NAME)Department(DEPARTMENT_ID, DEPARTMENT_NAME, MANAGER_ID, LOCATION_ID)Location(LOCATION_ID,STREET_ADDRESS,POSTAL_CODE,CITY,STATE_PROVINCE,COUNTRY_ID) Write a query in SQL to display the DEPARTMENT_NAME of all those Departments whoseDEPARTMENT_ID is greater than the DEPARTMENT_ID of Physics department. Write a Query in SQL to show the FIRST_NAME of all those employees whose salary is lessthan the salary of all those employees whose MANAGER_ID is 101 or 102.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education