HW01
.docx
keyboard_arrow_up
School
New Jersey Institute Of Technology *
*We aren’t endorsed by this school
Course
434
Subject
Computer Science
Date
May 4, 2024
Type
docx
Pages
10
Uploaded by JusticeUniverse25366 on coursehero.com
All PL/SQL work needs to be done with SQL Developer. All database work needs to be done in Oracle.
1)
a)
Write a PL/SQL function called CONSTANT_E that takes an argument N and sends to
the screen the number e using the following formula:
CS 434 Spring 2024
HOMEWORK 1
General Instructions. Read this carefully.
This is more important than the individual questions.
There are NO GROUP HOMEWORKS IN THIS CLASS. YOU NEED TO WORK ALONE.
1) Do not copy code from any other person. You can ask questions and get answers, but NEVER copy code. Also, do not copy and paste English text unless I specifically permit it. NEVER.
2) SHOW EVERYTHING. Anything you don't show will be automatically assumed as not done.
Don't logically argue that "of course, you must have done it." If we don't see it, then it is not done.
3) There will be no half points. Questions worth 1 point will be graded "all or nothing."
Points will appear in [ ] brackets.
The whole homework is worth 50 points.
If you miss the due date by up to one week, there will be a late penalty of 8 points subtracted.
If you miss the due date by MORE than a week you will get ZERO points.
The due date is Monday, February 19, 2024, 4:00 PM.
Your file name must have the format: LASTNAME_firstname_HWK1.doc (or .docx)
Example: CONSTANT_E(5) should send to the screen:
N = 5, e = 2,716667
Copy/paste your PL/SQL code (both functions and main program) at the first red arrow
► CREATE OR REPLACE FUNCTION CONSTANT_E(N IN NUMBER) RETURN NUMBER
IS
e_Val number := 1;
factorial number := 1;
BEGIN
for i IN 1..N
loop
e_Val := e_Val + (1 / factorial);
end loop;
DBMS_OUTPUT.PUT_LINE('N = ' || N || ',' || 'e = ' || e_Val);
RETURN e_Val;
END CONSTANT_E;
/
DECLARE
N number;
BEGIN
N := CONSTANT_E(5);
END;
/
1)
b)
Write a PL/SQL function called E_to_X that takes an arguments N and X and sends to
the screen the number e
x
using the following formula:
Example: E_to_X (5,3) should send to the screen:
X=3, N=5
Copy/paste your PL/SQL code (both functions and main program) at the first red arrow
► CREATE OR REPLACE FUNCTION E_to_X(N IN NUMBER, X IN NUMBER) RETURN NUMBER IS
e_to_x number := 1;
factorial number := 1;
BEGIN
for i in 1..N loop
power_x := power_x * X;
e_to_x := e_to_x + (power_x / factorial);
end loop;
DBMS_OUTPUT.PUT_LINE('X = ' || X || ',' || 'N = ' || N || ',' || 'e_to_x = ' || e_to_x);
RETURN e_to_x;
END E_to_X;
/
DECLARE
N number;
BEGIN
N := E_to_X(5,3);
END;
/
2)
The goal of this problem is to load some health data from the government into our Oracle
Database and use it to answer a few questions. (This will be continued in the next homework.)
Go to: https://ephtracking.cdc.gov/
Click on Explore Data
STEP 1: CONTENT
Click on “Select Content Area” so that you get “Drinking Water”.
Choose “Public Water Use” on the second drop-down menu.
Choose “Annual Number of People Receiving Water” on the third drop-down menu.
STEP 2: GEOGRAPHY TYPE
National by State
STEP 3: GEOGRAPHY
All States
STEP 4: TIME
2022
2021
2020
2019
STEP 5: ADVANCED OPTIONS
No Advanced Options
Then download the data and save it as a DrinkingWater.CSV file. Look at the Map. Note the menu that lets you choose between the four years.
Ask yourself these NON-CREDIT questions: What state has the highest value? What state has the lowest value? What does the number mean? Why do you think the state(s) with the highest value(s) have the highest value? Even though these are non-credit questions, I would like you to attempt to write answers. If they are wrong, you don’t lose anything.
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
Develop a two small PL/SQL programs.
1. Enter students ID from the keyboard. The program then finds student's first name, last name and phone, stores them in variables and prints them on the screen.
2. Similar to the above, only this time the program will receive student's first name only (instead of student's ID)Then program finds full name and address and prints it on the screen.
For both programs please implement NO_DATA_FOUND and TOO_MANY_ROWS exceptions. (please refer to chapter 8 in PL/SQL by Example book)For number 2 program, display a message "Possibly you have two or more students with the first name ...." in TOO_MANY_ROWS exception block.
arrow_forward
what is the best method to check a database for information entered into a search bar by a user?
for example, my database will have many animals. i want to make sure they come up appropriately, or that a message will be shown to the user that the animal is not in this list. i need to create a function that will do this
arrow_forward
INFO 2303 Database Programing
Assignment # : PL/SQL Procedure & Function Practice
Note: PL/SQL can be executed in SQL*Plus or SQL Developer or Oracle Live SQL.
Write a function that takes patient date of birth. If the patient born after 30th June 1990 then he/she will be required to set appointment for immunization. Call this function from anonymous block to allow the user to enter the patient ID.
Expected output:
Enter the patient ID: 168
The status of X-immunization : REQUIRED
arrow_forward
Given is a Python program that connects to a sqlite database and has one table called writers with two columnns:
name - the name of a writer
num - the number of works the writer has written
The writers table originally has the following data:
name, num Jane Austen,6 Charles Dickens,20 Ernest Hemingway,9 Jack Kerouac,22 F. Scott Fitzgerald,8 Mary Shelley,7 Charlotte Bronte,5 Mark Twain,11 Agatha Christie,73 Ian Flemming,14 J.K. Rowling,14 Stephen King,54 Oscar Wilde,1
Update the Python program to ask the user if they want to update entries or add new entries. If the name entered already exists in the writers table then the database record is updated, overwriting the original contents. If the name does not exist in the writers table, then add a new record with the writer's name and number of works. The following TODO sections must be completed.
Check if a writer exists in the writers table
If the writer exists in the table, locate an entry to be updated by writer's name and update…
arrow_forward
Given is a Python program that connects to a sqlite database and has one table called writers with two columnns:
name - the name of a writer
num - the number of works the writer has written
The writers table originally has the following data:
name, num Jane Austen,6 Charles Dickens,20 Ernest Hemingway,9 Jack Kerouac,22 F. Scott Fitzgerald,8 Mary Shelley,7 Charlotte Bronte,5 Mark Twain,11 Agatha Christie,73 Ian Flemming,14 J.K. Rowling,14 Stephen King,54 Oscar Wilde,1
Update the Python program to ask the user if they want to update entries or add new entries. If the name entered already exists in the writers table then the database record is updated, overwriting the original contents. If the name does not exist in the writers table, then add a new record with the writer's name and number of works. The following TODO sections must be completed.
Check if a writer exists in the writers table
If the writer exists in the table, locate an entry to be updated by writer's name and update the…
arrow_forward
Given is a Python program that connects to a sqlite database and has one table called writers with two columnns:
name - the name of a writer
num - the number of works the writer has written
The writers table originally has the following data:
name, num
Jane Austen,6
Charles Dickens,20
Ernest Hemingway,9
Jack Kerouac,22
F. Scott Fitzgerald,8
Mary Shelley,7
Charlotte Bronte,5
Mark Twain,11
Agatha Christie,73
Ian Flemming,14
J.K. Rowling,14
Stephen King,54
Oscar Wilde,1
arrow_forward
Given is a Python program that connects to a sqlite database and has one table called writers with two columnns:
name - the name of a writer
num - the number of works the writer has written
The writers table originally has the following data:
name, num Jane Austen,6 Charles Dickens,20 Ernest Hemingway,9 Jack Kerouac,22 F. Scott Fitzgerald,8 Mary Shelley,7 Charlotte Bronte,5 Mark Twain,11 Agatha Christie,73 Ian Flemming,14 J.K. Rowling,14 Stephen King,54 Oscar Wilde,1
Update the Python program to ask the user if they want to update entries or add new entries. If the name entered already exists in the writers table then the database record is updated, overwriting the original contents. If the name does not exist in the writers table, then add a new record with the writer's name and number of works. The following TODO sections must be completed.
Check if a writer exists in the writers table
If the writer exists in the table, locate an entry to be updated by writer's name and update the…
arrow_forward
Blood Donor Management System The blood donation clinic is looking at creating a database to store the donors’ details. The clinic is hoping to start by adding donor names and assign them unique IDs. They then want to add their details and relevant information such as blood type, first name, last name and contact number.
Write an interactive program that allows a clinic administrator to store donors’ details on the SQLite 3 database with the following specifications:
2.1 The program must have a menu for the administrator to select one of the following:• Register a donor• Display the record of all registered donors• Update the existing record• Delete a record• Exit the program
2.2 The program should display feedback messages for any successfully executed task and use exception handlers for any errors produced in the code.
2.3 The program must have the following functions:• The donor_register function to add donors• The donor_update function to update the donor details• The donor_remove…
arrow_forward
A computer store uses a database to track inventory. The database has a table named
Inventory
, with the following columns:
ProductID INTEGER PRIMARY KEY NOT NULL
ProductName TEXT
QtyOnHand INTEGER
Cost REAL
Also assume that the
cur
variable references a
Cursor
object for the database. Write Python code that uses the
Cursor
object to execute an SQL statement that deletes the row in the
Inventory
table in which
ProductID
is equal to 12.
arrow_forward
/* Database Systems, 8th Ed., Rob/Coronel *//* Type of SQL : SQL Server */
CREATE TABLE CUSTOMER (CUST_NUM int,CUST_LNAME varchar(20),CUST_FNAME varchar(20),CUST_BALANCE float(8));INSERT INTO CUSTOMER VALUES('1000','Smith','Jeanne','1050.11');INSERT INTO CUSTOMER VALUES('1001','Ortega','Juan','840.92');
/* -- */
CREATE TABLE CUSTOMER_2 (CUST_NUM int,CUST_LNAME varchar(20),CUST_FNAME varchar(20));INSERT INTO CUSTOMER_2 VALUES('2000','McPherson','Anne');INSERT INTO CUSTOMER_2 VALUES('2001','Ortega','Juan');INSERT INTO CUSTOMER_2 VALUES('2002','Kowalski','Jan');INSERT INTO CUSTOMER_2 VALUES('2003','Chen','George');
/* -- */
CREATE TABLE INVOICE (INV_NUM int,CUST_NUM int,INV_DATE datetime,INV_AMOUNT float(8));INSERT INTO INVOICE VALUES('8000','1000','3/23/2010','235.89');INSERT INTO INVOICE VALUES('8001','1001','3/23/2010','312.82');INSERT INTO INVOICE VALUES('8002','1001','3/30/2010','528.10');INSERT INTO INVOICE VALUES('8003','1000','4/12/2010','194.78');INSERT INTO INVOICE…
arrow_forward
Computer Science
* IN SQL* Write an SQL statement that selects all customers with a city starting with any character, followed by "land".
arrow_forward
Consider a database with the following tables:
v Patient(PatientID. PatientName, NumberOfVisits)
v Doctor(DoctorID, DoctorName)
v Appointment(ApplD, DoctorID, PatientID. Date, time)
Write SQL statements or the necessary steps that do the following:
a) Write the SQL statements required to create the above tables. You have to choose the best data
type for each column, and all necessary keys (primary and foreign
arrow_forward
Write a function called ValidSupplier(SupplierID) that takes as its only input a SupplierID.
If the supplier exists in the database your function should return True otherwise it should return False
For example:
Test
Result
print(ValidSupplier(13))
True
arrow_forward
I am trying ro create this java program , i have the table in my tatabase. lam using postgresql ii don't know
what to do.
Here is the question
Write a Java Program to simulate an interactive SQL interface like psql. It should allow the
user to query and update the tables in the database. Make sure your program prints out the
query result (with column headings) or the update status (e.g., the number of rows
deleted/updated/inserted)
arrow_forward
In java create an application to manage your data base
information the database is already created in mysql
tables, the tables are fill, So the user can use your
database application user friendly
Retrieve all data: Given a table name, retrieve all data
from the table and present it to the user.
Average: Given a table name and a column name, return
the average of the column. Here the assumption is that
the column type will be numeric (e.g., cost column).
Insert: Given a table name, your program should show
the column names of that table and ask the users to
input new data to the table. In case of errors, your
program should directly show the MySQL errors to the
users.
Assumption 1: Users will enter data according to the
database constraints.
Assumption 2: Users will input one record at a time.
Delete: Given a table name, your program should show
the column names of that table and ask the users to
input data that they want to delete.
Assumption 1: Users will enter data according to the…
arrow_forward
Translate the following pandas statement in Python to a SQL query so that it can be executed on the SQL database.
dfdata[(10*dfdata['cases']>dfdata['cases'])&(dfdata['date']=='2020-10-10')]['county']
arrow_forward
Develop a two small PL/SQL programs.
1. Enter instructor ID from the keyboard. The program then finds instrutor's first name, last name and phone, stores them in variables and prints them on the screen. USE WHILE LOOP to print all instructors while selecting them one by one in the loop.
2. Similar to the above, only this time the program will receive student's first name only (instead of ID)Then program finds full name and address and prints it on the screen (work with STUDENT table here)
For both programs please implement NO_DATA_FOUND and TOO_MANY_ROWS exceptions. (please refer to chapter 8 in PL/SQL by Example book)For number 2 program, display a message "Possibly you have two or more students with the first name ...." in TOO_MANY_ROWS exception block.
1* select table_name from user_tablesSQL> desc studentName Null? Type----------------------------------------- -------- ----------------------------STUDENT_ID NOT NULL NUMBER(8)SALUTATION VARCHAR2(5)FIRST_NAME…
arrow_forward
Use Python Programming - restaurant reservation program. The application offers different reservation rate for adults and children. (see sample below)
RESTAURANT RESERVATION SYSTEMSystem Menua. View all Reservationsb. Make Reservationc. Delete Reservationd. Generate Reporte. Exit
2. When the VIEW RESERVATIONS is clicked, this will display all the reservations made:
# Date Time Name Adults Children 1 Nov 10, 2020 10:00 am John Doe 1 1 2 Nov 25, 202011:00 am Michelle Franks 2 1 3 Dec 10, 2020 9:00 am Ella Flich 1 1 4 Dec 21, 2020 12:00 pmDylan Cloze 2 1
3. If the user selects MAKE RESERVATION, the user needs to input the following:
a. Name (String)b. Date (String)c. Time (String)d. No of Adults (Integer)e. No of Children (Integer)
Note: Adult is 500 per head and Kids is 300 per head reservation, save the data in a text file.
4. If DELETE RESERVATION is selected, the user needs to input the reservation number to remove the existing reservation.
5. If the GENERATE REPORT is clicked,…
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
Use Python Programming - restaurant reservation program. The application offers different reservation rate for adults and children. (see sample below)
RESTAURANT RESERVATION SYSTEMSystem Menua. View all Reservationsb. Make Reservationc. Delete Reservationd. Generate Reporte. Exit
2. When the VIEW RESERVATIONS is clicked, this will display all the reservations made:
# Date Time Name Adults Children 1 Nov 10, 2020 10:00 am John Doe 1 1 2 Nov 25, 202011:00 am Michelle Franks 2 1 3 Dec 10, 2020 9:00 am Ella Flich 1 1 4 Dec 21, 2020 12:00 pmDylan Cloze 2 1
3. If the user selects MAKE RESERVATION, the user needs to input the following:
a. Name (String)b. Date (String)c. Time (String)d. No of Adults (Integer)e. No of Children (Integer)
Note: Adult is 500 per head and Kids is 300 per head reservation, save the data in a text file.
4. If DELETE RESERVATION is selected, the user needs to input the reservation number to remove the existing reservation.
5. If the GENERATE REPORT is clicked,…
arrow_forward
Databases are used to store different kinds of data such as names, currency, text, graphics, etc. Determining the appropriate data type for each attribute is important for database performance, storage size, and conducting accurate analysis on databases. As with other programming languages, SQL supports many data types. However, you will mostly use two categories while writing SQL queries: Characters, and numbers.
Consider the following standard SQL data types:
Characters
char
varchar
Numbers
integer
decimal
float
Different data types could be used for the same attribute. For example, both char and varchar could be used to store “names” in a database. Examine the attributes for the Characters and Numbers data types.
Using specific examples, compare data types for each category. For example, why you should choose char rather than varchar or opposite?
arrow_forward
Write a PL/SQL function that accepts employee ID as input
and returns employee first name , last name and email . Also,
write an anonymous block with the function call
Use the employees object of Oracle Live SQL HR Scheme, Employees
object descriptions is given here.
Column
Null?
Туре
NOT
EMPLOYEE ID
FIRST NAME
NULL
NUMBER(6,0)
VARCHAR2(20)
NOT
LAST NAME
NULL
VARCHAR2(25)
NOT
EMAIL
NULL
VARCHAR2(25)
PHONE NUMBER
VARCHAR2(20)
NOT
HIRE DATE
NULL
DATE
NOT
NULL
JOB ID
VARCHAR2(10)
SALARY
NUMBER(8,2)
COMMISSION_PCT
NUMBER(2,2)
MANAGER_ ID
NUMBER(6,0)
DEPARTMENT ID
NUMBER(4,0)
arrow_forward
Create a function in your own database that takes two parameters: A year parameter A month parameter The function then calculates and returns the total sales of the requested period for each territory. Include the territory id, territory name, and total sales dollar amount in the returned data. Format the total sales as an integer. Hints: a) Use the TotalDue column of the Sales.SalesOrderHeader table in an AdventureWorks database for calculating the total sale. b) The year and month parameters should have the SMALLINT data type.
arrow_forward
Code should be in Python
Prompt the user for a title for data. Output the title.Ex:
Enter a title for the data:
Number of Novels Authored
You entered: Number of Novels Authored
Prompt the user for the headers of two columns of a table. Output the column headers.Ex:
Enter the column 1 header:
Author name
You entered: Author name
Enter the column 2 header:
Number of novels
You entered: Number of novels
Prompt the user for data points. Data points must be in this format: string, int. Store the information before the comma into a string variable and the information after the comma into an integer. The user will enter -1 when they have finished entering data points. Output the data points. Store the string components of the data points in a list of strings. Store the integer components of the data points in a list of integers.Ex:
Enter a data point (-1 to stop input):
Jane Austen, 6
Data string: Jane Austen
Data integer: 6
Perform error checking for the data point entries. If any of the…
arrow_forward
Common Time Zones
Function Name: commonTimeZones()
Parameters: code1( str ) , code2( str )
Returns: list of common time zones ( list )
Description: You and your friend live in different countries, but you figure there's a chance that
both of you might be in the same time zone. Thus, you want to find out the list of possible time
zones that you and your friend could both be in. Given two country codes, write a function that returns a list of the time zones the two countries have in common. Be sure not to include any duplicate time zones. If the two country codes do not have any common time zones, return the string 'No Common Time Zones' instead.
Note: You can assume that the codes will always be valid.
example test cases:
>>> commonTimeZones('can', 'usa')
['UTC-08:00', 'UTC-07:00', 'UTC-06:00', 'UTC-05:00', 'UTC-04:00']
>>> commonTimeZones('rus', 'chn')
['UTC+08:00']
For this assignment, use the REST countries API…
arrow_forward
Common Time Zones
Function Name: commonTimeZones()
Parameters: code1( str ), code2( str)
Returns: list of common time zones ( list )
Description: You and your friend live in different countries, but you figure there's a chance that
both of you might be in the same time zone. Thus, you want to find out the list of possible time
zones that you and your friend could both be in. Given two country codes, write a function that
returns a list of the time zones the two countries have in common. Be sure not to include any
duplicate time zones. If the two country codes do not have any common time zones, return the
string 'No Common Time Zones' instead.
Note: You can assume that the codes will always be valid.
example test cases:
>>> commonTimeZones('can', 'usa')
[UTC-08:00', 'UTC-07:00', 'UTC-06:00', 'UTC-05:00', 'UTC-04:00]
>>> commonTimeZones('rus', 'chn')
[UTC+08:00]
For this assignment, use the REST countries API
(https://restcountries.com/#api-endpoints-v2).
For all of your requests, make…
arrow_forward
Question 8
Oracle compiler
implicitly convert the value from some data type to others.
can
True
False
arrow_forward
Question 8
Find the score (mean accuracy) of your knn classifier using x_test and y_test.
This function should return a float between 0 and 1
[ ]: def answer_eight():
# YOUR CODE HERE
raise NotImplementedError()
[ ]:
arrow_forward
All do. Else report.
arrow_forward
Assume that you have a product code that has the following format: XXXXNNN
Where X is a character and N is a digit. Notice that the length of the character part is not fixed, it may range from 2 to 4 characters, while the length of the second part may range from 2 to 3 digits but the first digit from the left is always 0 (zero).
Write a PL/SQL program to separate the code into its two parts as shown in the following example: if the input is ABC031, the output should be:
Product Name is: ABC
Serial Number is: 031
arrow_forward
Do the needs to code.
arrow_forward
How does data encapsulation work, and when would you want to utilize it?
arrow_forward
What is the Test Data Method?
arrow_forward
SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Related Questions
- Develop a two small PL/SQL programs. 1. Enter students ID from the keyboard. The program then finds student's first name, last name and phone, stores them in variables and prints them on the screen. 2. Similar to the above, only this time the program will receive student's first name only (instead of student's ID)Then program finds full name and address and prints it on the screen. For both programs please implement NO_DATA_FOUND and TOO_MANY_ROWS exceptions. (please refer to chapter 8 in PL/SQL by Example book)For number 2 program, display a message "Possibly you have two or more students with the first name ...." in TOO_MANY_ROWS exception block.arrow_forwardwhat is the best method to check a database for information entered into a search bar by a user? for example, my database will have many animals. i want to make sure they come up appropriately, or that a message will be shown to the user that the animal is not in this list. i need to create a function that will do thisarrow_forwardINFO 2303 Database Programing Assignment # : PL/SQL Procedure & Function Practice Note: PL/SQL can be executed in SQL*Plus or SQL Developer or Oracle Live SQL. Write a function that takes patient date of birth. If the patient born after 30th June 1990 then he/she will be required to set appointment for immunization. Call this function from anonymous block to allow the user to enter the patient ID. Expected output: Enter the patient ID: 168 The status of X-immunization : REQUIREDarrow_forward
- Given is a Python program that connects to a sqlite database and has one table called writers with two columnns: name - the name of a writer num - the number of works the writer has written The writers table originally has the following data: name, num Jane Austen,6 Charles Dickens,20 Ernest Hemingway,9 Jack Kerouac,22 F. Scott Fitzgerald,8 Mary Shelley,7 Charlotte Bronte,5 Mark Twain,11 Agatha Christie,73 Ian Flemming,14 J.K. Rowling,14 Stephen King,54 Oscar Wilde,1 Update the Python program to ask the user if they want to update entries or add new entries. If the name entered already exists in the writers table then the database record is updated, overwriting the original contents. If the name does not exist in the writers table, then add a new record with the writer's name and number of works. The following TODO sections must be completed. Check if a writer exists in the writers table If the writer exists in the table, locate an entry to be updated by writer's name and update…arrow_forwardGiven is a Python program that connects to a sqlite database and has one table called writers with two columnns: name - the name of a writer num - the number of works the writer has written The writers table originally has the following data: name, num Jane Austen,6 Charles Dickens,20 Ernest Hemingway,9 Jack Kerouac,22 F. Scott Fitzgerald,8 Mary Shelley,7 Charlotte Bronte,5 Mark Twain,11 Agatha Christie,73 Ian Flemming,14 J.K. Rowling,14 Stephen King,54 Oscar Wilde,1 Update the Python program to ask the user if they want to update entries or add new entries. If the name entered already exists in the writers table then the database record is updated, overwriting the original contents. If the name does not exist in the writers table, then add a new record with the writer's name and number of works. The following TODO sections must be completed. Check if a writer exists in the writers table If the writer exists in the table, locate an entry to be updated by writer's name and update the…arrow_forwardGiven is a Python program that connects to a sqlite database and has one table called writers with two columnns: name - the name of a writer num - the number of works the writer has written The writers table originally has the following data: name, num Jane Austen,6 Charles Dickens,20 Ernest Hemingway,9 Jack Kerouac,22 F. Scott Fitzgerald,8 Mary Shelley,7 Charlotte Bronte,5 Mark Twain,11 Agatha Christie,73 Ian Flemming,14 J.K. Rowling,14 Stephen King,54 Oscar Wilde,1arrow_forward
- Given is a Python program that connects to a sqlite database and has one table called writers with two columnns: name - the name of a writer num - the number of works the writer has written The writers table originally has the following data: name, num Jane Austen,6 Charles Dickens,20 Ernest Hemingway,9 Jack Kerouac,22 F. Scott Fitzgerald,8 Mary Shelley,7 Charlotte Bronte,5 Mark Twain,11 Agatha Christie,73 Ian Flemming,14 J.K. Rowling,14 Stephen King,54 Oscar Wilde,1 Update the Python program to ask the user if they want to update entries or add new entries. If the name entered already exists in the writers table then the database record is updated, overwriting the original contents. If the name does not exist in the writers table, then add a new record with the writer's name and number of works. The following TODO sections must be completed. Check if a writer exists in the writers table If the writer exists in the table, locate an entry to be updated by writer's name and update the…arrow_forwardBlood Donor Management System The blood donation clinic is looking at creating a database to store the donors’ details. The clinic is hoping to start by adding donor names and assign them unique IDs. They then want to add their details and relevant information such as blood type, first name, last name and contact number. Write an interactive program that allows a clinic administrator to store donors’ details on the SQLite 3 database with the following specifications: 2.1 The program must have a menu for the administrator to select one of the following:• Register a donor• Display the record of all registered donors• Update the existing record• Delete a record• Exit the program 2.2 The program should display feedback messages for any successfully executed task and use exception handlers for any errors produced in the code. 2.3 The program must have the following functions:• The donor_register function to add donors• The donor_update function to update the donor details• The donor_remove…arrow_forwardA computer store uses a database to track inventory. The database has a table named Inventory , with the following columns: ProductID INTEGER PRIMARY KEY NOT NULL ProductName TEXT QtyOnHand INTEGER Cost REAL Also assume that the cur variable references a Cursor object for the database. Write Python code that uses the Cursor object to execute an SQL statement that deletes the row in the Inventory table in which ProductID is equal to 12.arrow_forward
- /* Database Systems, 8th Ed., Rob/Coronel *//* Type of SQL : SQL Server */ CREATE TABLE CUSTOMER (CUST_NUM int,CUST_LNAME varchar(20),CUST_FNAME varchar(20),CUST_BALANCE float(8));INSERT INTO CUSTOMER VALUES('1000','Smith','Jeanne','1050.11');INSERT INTO CUSTOMER VALUES('1001','Ortega','Juan','840.92'); /* -- */ CREATE TABLE CUSTOMER_2 (CUST_NUM int,CUST_LNAME varchar(20),CUST_FNAME varchar(20));INSERT INTO CUSTOMER_2 VALUES('2000','McPherson','Anne');INSERT INTO CUSTOMER_2 VALUES('2001','Ortega','Juan');INSERT INTO CUSTOMER_2 VALUES('2002','Kowalski','Jan');INSERT INTO CUSTOMER_2 VALUES('2003','Chen','George'); /* -- */ CREATE TABLE INVOICE (INV_NUM int,CUST_NUM int,INV_DATE datetime,INV_AMOUNT float(8));INSERT INTO INVOICE VALUES('8000','1000','3/23/2010','235.89');INSERT INTO INVOICE VALUES('8001','1001','3/23/2010','312.82');INSERT INTO INVOICE VALUES('8002','1001','3/30/2010','528.10');INSERT INTO INVOICE VALUES('8003','1000','4/12/2010','194.78');INSERT INTO INVOICE…arrow_forwardComputer Science * IN SQL* Write an SQL statement that selects all customers with a city starting with any character, followed by "land".arrow_forwardConsider a database with the following tables: v Patient(PatientID. PatientName, NumberOfVisits) v Doctor(DoctorID, DoctorName) v Appointment(ApplD, DoctorID, PatientID. Date, time) Write SQL statements or the necessary steps that do the following: a) Write the SQL statements required to create the above tables. You have to choose the best data type for each column, and all necessary keys (primary and foreignarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr