Computer Science Canada Indexing Problem. |
Author: | Prok [ Sun May 17, 2009 8:15 pm ] |
Post subject: | Indexing Problem. |
This is a project for school (not asking for an answer so please read further), I'm making a crazy simple database, I'll post the assignment at the end for reference but for right now i'm just going to post what i have a problem with: Index: The index function will be able to index the data on any given field in ascending or descending order. The Index function should prompt the user to enter the field to be indexed. In addition, they should indicate if they want to index in ascending or descending order. To complete this task the sorting should be done using merge sort, heap sort or quick sort. Also, when you are indexing, you should not move entire records. The whole record should not be read in the program. Only the primary key and the indexed field should be stored in the program?s memory. I can't think of what he possibly means and it's due next class so I have no time to ask questions to my professor. He wants me to sort data without ever moving data? If you can better understand this please give a simple explanation of how i might go about doing this. Nothing more than code snippets if they're necessary... Just want a general explanation of how this might be done... please and thank you... **--**--**--**--**--**--**--**--**--**--**--**--**--**--**--**--**--**--**--**--**--**--**--**--**--**--**--**--**--**--**--**--**--**--**-- (full Assignment): Write a task that will perform some of the functions performed by a simple employee database. The various functions will be laid out below. Data: Each record will consist of six attributes, one if with is the primary key. The primary key will be automatically assigned to a record when the record is created. The fields for the record are as follows: ID: integer (automatically generated by program) Last name: 20 character max First Name: 20 character max Social Security Number: 11 character max (include ?-?) Salary: float Age: integer The data should be stored in a randomly accessible file. There should be at least 20 records stored in the file. Index: The index function will be able to index the data on any given field in ascending or descending order. The Index function should prompt the user to enter the field to be indexed. In addition, they should indicate if they want to index in ascending or descending order. To complete this task the sorting should be done using merge sort, heap sort or quick sort. Also, when you are indexing, you should not move entire records. The whole record should not be read in the program. Only the primary key and the indexed field should be stored in the program?s memory. Query: The query function will allow the user to perform basic queries by typing in SQL statements. This function should support the following SQL statements: ? Select * from table (basically it displays all records) ? Select <field> from table (displays only the <field> listed from every record) ? Select * from table where <field> = value (displays all records where <field> = value) ? Select <field> from table where <field> = value (displays only the <field> of all records where field = value) Display: The display function should list all of the records in order based on the last indexing. In addition, the field that was indexed last should be the first field listed for each record. If no indexing was performed before choosing the display function, then the records should be displayed in order based on the primary key. Search: The search feature should employ a search algorithm that performs at log base-2 or better. The search feature should prompt the user to enter a social security number. The program should print the record if one exists that matches the social security number, otherwise tell the user that the number is not in the system. If you are using the binary search method, I suggest you call the indexing method to sort the social security numbers Add Record: This feature allows the users to add a record to the file. In addition, it should automatically generate a primary key value for the record. The program should insure that the new record has a unique social security number and that the format of the number is entered correctly (xxx-xx-xxxx) Delete Record: This function will just delete a record from the file. File: The file should store the records as a random access file. This will allow the program to access individual records without having to read the whole database into memory. Menu: The menu function should display all of the abovementioned choices. Each function should be associated with an integer value. The program should prompt the user to enter in all of the choices at once. Then, the choices will be placed in a queue to track the order of the requests and executed one after another. |
Author: | jbking [ Sun May 17, 2009 8:56 pm ] |
Post subject: | Re: Indexing Problem. |
Basically what you are to produce is the list of indices of the data sorted in that particular fashion. For example, picture the data being written into a simple array so that each record can be accessed via an index in the range of 0 to n-1, for n records. Thus, what is being sought after is which index should be first, second, third, .. [n-1]th, overall. This can be efficient since you aren't moving the records but rather creating a list of indices if the data is sorted this way or that. For example, how could you access all the records by salary descending or last name ascending without actually moving the data. Does that help or would you like a more specific example to elaborate on that? |
Author: | Prok [ Sun May 17, 2009 10:33 pm ] |
Post subject: | Re: Indexing Problem. |
ohhh i think i got it now thanks alot for teh memory jog i know exactly what to do now really appreciate the help ![]() i think this forum has a new active member ![]() |