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 Systems: Design, Implementation, & Management
12th Edition
ISBN:9781305627482
Author:Carlos Coronel, Steven Morris
Publisher:Carlos Coronel, Steven Morris
Chapter7: Introduction To Structured Query Language (sql)
Section: Chapter Questions
Problem 97C: The following tables provide a very small portion of the data that will be kept in the database....
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
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781305627482
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781285196145
Author:
Steven, Steven Morris, Carlos Coronel, Carlos, Coronel, Carlos; Morris, Carlos Coronel and Steven Morris, Carlos Coronel; Steven Morris, Steven Morris; Carlos Coronel
Publisher:
Cengage Learning