Need some help understanding this Python program that creates a new database named DSUCollege.db and calls 4 functions. The function named create_table will create a table in the DSUCollege.db database called students that has five fields: student_id, first_name, last_name, major, and gpa.  The first_name, last_name, and major columns should be TEXT data types, the student_id column should be an INTEGER datatype and gpa should be a REAL datatype (link to SQLite Data typesLinks to an external site.). Before creating the table, add code to drop the table.  After the table has been created, display a message that the table has been created successfully. The function named populate_table populates the students table with the following values: student_id first_name last_name major gpa 1111 Dave Grohl Music 4.0 2222 Belinda Carlisle Accounting 3.5 3333 Joe Elliot Computer Science 2.8 4444 Angus Young Accounting 2.1 5555 Susanna Hoffs Music 3.1 6666 Debbie Harry Computer Science 3.4 7777 Saul Hudson Music 2.7 8888 Paul Hewson Computer Science 1.8 After the seven rows have been added, display a message that the table has been populated.   After the table has been populated a function named update_table should be called that creates and runs SQL statements to do the following: Dave Grohl (id 1111) has graduated, delete him from the table and display a message that the delete was successful. Use the id field to locate the correct record to delete. Paul Hewson (id 8888) has changed majors to Music, update his major to reflect the change and display a message that the update has been successful. Use the id field to locate the correct record to update. Debbie Harry's (id 6666) gpa has increased to 4.0, update her gpa to 4.0 and display a message that the update was successful. Use the id field to locate the correct record to update. After the updates have been completed,  a function named query_table  should be called that creates and runs the following queries: Create a query to display all information about all students in alphabetical order (a to z) by last_name.  Create a query to display the first_name and last_name of all students who major in Music.  Create a query to display the first_name, last_name, major and gpa with gpa  >= 3.0, order the query results by gpa in descending order.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Need some help understanding this Python program that creates a new database named DSUCollege.db and calls 4 functions.

The function named create_table will create a table in the DSUCollege.db database called students that has five fields: student_id, first_name, last_name, major, and gpa.  The first_name, last_name, and major columns should be TEXT data types, the student_id column should be an INTEGER datatype and gpa should be a REAL datatype (link to SQLite Data typesLinks to an external site.). Before creating the table, add code to drop the table.  After the table has been created, display a message that the table has been created successfully.

The function named populate_table populates the students table with the following values:

student_id first_name last_name major gpa
1111 Dave Grohl Music 4.0
2222 Belinda Carlisle Accounting 3.5
3333 Joe Elliot Computer Science 2.8
4444 Angus Young Accounting 2.1
5555 Susanna Hoffs Music 3.1
6666 Debbie Harry Computer Science 3.4
7777 Saul Hudson Music 2.7
8888 Paul Hewson Computer Science 1.8

After the seven rows have been added, display a message that the table has been populated.  

After the table has been populated a function named update_table should be called that creates and runs SQL statements to do the following:

  • Dave Grohl (id 1111) has graduated, delete him from the table and display a message that the delete was successful. Use the id field to locate the correct record to delete.
  • Paul Hewson (id 8888) has changed majors to Music, update his major to reflect the change and display a message that the update has been successful. Use the id field to locate the correct record to update.
  • Debbie Harry's (id 6666) gpa has increased to 4.0, update her gpa to 4.0 and display a message that the update was successful. Use the id field to locate the correct record to update.

After the updates have been completed,  a function named query_table  should be called that creates and runs the following queries:

  • Create a query to display all information about all students in alphabetical order (a to z) by last_name. 
  • Create a query to display the first_name and last_name of all students who major in Music. 
  • Create a query to display the first_name, last_name, major and gpa with gpa  >= 3.0, order the query results by gpa in descending order.

 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Fundamentals of Datawarehouse
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
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)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education