Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a menu driven program to create and operate on a relational database that, prospectively, can be used by a library. One relation is

imageimage

Write a menu driven program to create and operate on a relational database that, prospectively, can be used by a library. One relation is stored in one data file. Because these files can have different structure, the information about this structure is stored in the system catalog dbFiles maintained by your program (which should be created only the first time you run your program!). This information includes the names and the widths of all columns. Write functions/methods create Table (), insert (), remove(), printFile(), and purge() that operate on these files. The createTable () function creates a file whose name and size are entered by the user. Here is an example (the underlined entries are typed by the user): enter table name: books enter column name and its length: author 20 enter column name and its length: title 20 enter column name and its length: callNo 5 enter column name and its length: After this, the text file books.db is created and column names author, title, and callNo and their sizes are inserted in dbFiles. insert () allows you to add new entries (records) to a file. For example, you may have the following sequence of entries after choosing the insert option: enter file name: books author: Burnett Frances title: The Secret Garden callNo: MN432 More entries (Y/n): author: Wesley John title: Journal callNo: PQ945 More entries (Y/n): n remove() allows you to remove any record from any file. The prompts may be similar to those for inserting records. When deleting a record, put only a tombstone in the data file and continue running your program. A tombstone can be some special character - e.g., the sharp sign # - which is written over the first character in the record. printFile () displays the content of a file as a table with aligned columns and column names as captions. After exit is chosen from the menu, call the function purge () to process all the data files to be found in dbFiles. Purging consists in permanently removing from each file all the records marked for removal. BOOKS PEOPLE dbFiles file name Author Burnett Frances Wesley John Pushkin Aleksander Bernhardt Sarah Genlis Stephanie Byron George Wesley Charles Byron George SSN 123456789 987654321 999123456 column name size books Author 20 books Title 20 books CallNo people Name people SSN 5 20 9 Title The Secret Garden Journal Evgeny Onegin Memoires Memoires The Giaour Hymns Beppo Name Duff Jes Butler Donald Kazanopulos Demos CallNo MN432 PQ945 AB123 KL765 KL766 NN333 SD120 XY768

Step by Step Solution

There are 3 Steps involved in it

Step: 1

include include include include include using namespace std ofstream outFile ifstream inFile struct relation string tableName vector columnName vector columnSize vector dbFiles maintain all relations ... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Statistics For Business And Economics

Authors: Paul Newbold, William Carlson, Betty Thorne

8th Edition

0132745658, 978-0132745659

More Books

Students also viewed these Programming questions

Question

=+d. What is the expected time for completing both tasks?

Answered: 1 week ago