Question: Create a program that can be used by a bookstore clerk. The program should allow the clerk to: add new books to the database, update

Create a program that can be used by a bookstore clerk. The program
should allow the clerk to:
add new books to the database,
update book information,
delete books from the database, and search the database to find a specific book.
Create a database called ebookstore and a table called book. The table
should have the following structure:
Populate the table with the above values. You can also add your own values
if you wish.
The program should present the user with the following menu:
Enter book
Update book
Delete book
Search books
0. Exit
The program should perform the function that the user selects. The
implementation of these functions is left up to you, but a demonstration of the
topics we have covered previously should be shown.
Part 2
Next, we will enhance the complexity of the database by introducing an
additional table.
Create a table called author in the ebookstore database. The table should
have the following structure: Populate the table with the above values, and any additional ones
necessary if you have added additional entries to the book table.
Add a 'View details of all books' option to the menu. The menu should
now look like this:
Enter book
Update book
Delete book
Search books
View details of all books
0. Exit
Add functionality to your program to display the book title, author name,
and country in a user-friendly way when the 'view details of all books'
option is selected. See the example below: (Hint: Use the zip() function).
Details
Title: The Table of Two Cities
Author's Name: Charles Dickens
Author's Country: England
Title: The Lion, the Witch and the Wardrobe
Author's Name: C.S. Lewis
Author's Country: Ireland
Title: Alice's Adventures in Wonderland
Author's Name: Lewis Carroll
Author's Country: England
Note that the book table contains the title column, while the author table
includes the name and country columns. The authorID column in the book table
serves as a foreign key, linking to a corresponding author with a matching id
(which is the primary key) in the author table. To retrieve the necessary
information from both tables, you should construct a query using an INNER JOIN.
This will allow you to obtain the relevant columns from both tables
simultaneously. Part 3
Finally, apply best practices for code maintainability by implementing the
following improvements:
Code modularity: Divide the program into smaller, reusable parts for
better maintainability and readability. This can be achieved by
implementing functions to handle specific functionalities, such as adding
books, updating books, deleting books, etc. Additionally, create functions to
encapsulate database-related operations, like establishing a database
connection and creating tables.
Error handling: Implement robust error handling to manage unexpected
user inputs and database errors. This will involve incorporating validation
checks and exception handling and providing user-friendly error messages.
Data validation: Ensure that user inputs are validated to prevent data
inconsistencies and security risks such as SQL injection attacks. For
example, validate that the book ID and author ID are integers and have
exactly four characters.
Backup and restore: Implement backup and restore mechanisms to
safeguard the database from data loss. To achieve this, create s
Finally, apply best practices for code maintainability by implementing the
following improvements:
Code modularity: Divide the program into smaller, reusable parts for
better maintainability and readability. This can be achieved by
implementing functions to handle specific functionalities, such as adding
books, updating books, deleting books, etc. Additionally, create functions to
encapsulate database-related operations, like establishing a database
connection and creating tables.
Error handling: Implement robust error handling to manage unexpected
user inputs and database errors. This will involve incorporating validation
checks and exception handling and providing user-friendly error messages.
Data validation: Ensure that user inputs are validated to prevent data
inconsistencies and security risks such as SQL injection attacks. For
example, validate that the book ID and author ID are integers and have
exactly four characters.
Backup and restore: Implement backup and restore mechanisms to
safeguard the database from data loss. To achieve this, create separate
functions to handle these functionalities and add corresponding options to
the menu for the user to 'Backup database' and 'Restore database'.
Refactoring: Identify redundant code and create functions to encapsulate
repetitive functionality, avoiding repetition in the codebase.
Debugging: Test your program to verify if it works as expected, and ensure
that any logical errors are resolved.
Documentation and style: The program must be well-documented, follow
good coding practices, and be styled according to the PEP 8 style guide to
maintain consistency and readability.
Create a program that can be used by a bookstore

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!