Consider any collection of data that you can organize in at least two ways. For example, you can order employees by either name or identification number and books by either title or author. Note that other information about the employees or books can be present in the database, but is not used to organize these items. Search keys are strings and are unique. Thus, in the previous examples, the identification number must be a string instead of an integer, and only one book per author is permitted. Choose any set of data that conforms to these requirements, and create a text file. Program behaviour. When your program begins execution, it should read your text file. It then should provide some typical database management operations, all under user control via an interface of your design. For example, you should be able to add an entry, remove an entry, display (that is, retrieve) an entry, and display all of the entries in search-key order. You should be able to use either of two search keys to designate the entry to be removed or displayed. Implementation notes. The entries in the database should be objects that contain two search keys and additional data, all of which appear in the text file. Thus, you need to design and implement a class of these objects. Although your program could create two dictionaries from these objects—one organized by one search key (such as the employee’s name) and the other organized by another search key (such as the identification number)—this approach could waste a substantial amount of memory due to the duplication of all of the data in both dictionaries. It could also lead to inconsistencies in the data if a programmer makes an error and only updates data in one dictionary but not the other. A better approach revises the ADT dictionary to provide operations according to two search keys. For example, you want to be able to remove either by name only or by identification number only. The underlying data structure for the dictionary’s implementation could be two other dictionaries or one of your own design so that you can organize the data in two ways: by name and by identification number, for example. To avoid duplicated data, store the data in a list and let each dictionary entry contain the position of the data in the list instead of the data itself. Your program can be specific to the type of database (employees, books, and so on), or it can be more general. For example, the search-key description that the user interface displays could be in the text file.
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here