Course number : COM 3360 Name : Steven Stuart Account name : steves Project : build a database editing system Date : 12/04/97 Directory : /proj/demsys/com3360-f97/steves/project This project consists of two somewhat discrete elements. The first is the ability to define and parse a data dictionary which is used to define a database consisting of a data file and fields associated with that data file. In addition other non-mandatory options can be used to specify options for the data dictionary as a whole (such as key fields by which to find records) as well as options that are field specific that are for the most part broken down into data integrity options (i.e. the ability to limit the values a variable can take) and formatting options. See the file test.dd for an in-depth description of the data dictionary format and specifiable options. The other major element of the project is to define an editing system for the database described by the previous data dictionary. It provides commands to maneuver through the data records, edit records by fields, append new records, find records by key values, give information on the database, etc. One feature is to parse in a file containing the valid commands as well as help information on these commands which the program can access. The project involves linking these 2 elements together to form a database editing system. Credits : --------- I used some of the ideas in the Library System with setting up a command system including command parsing. Class dictionary : ------------------ The class dictionary which was used is dd.cd. This includes the class dictionary for the data dictionary as well as the editing system. Program limitations: -------------------- Had I more time I would have added greater functionality in terms of commands in the editing system and more efficient I/O in the data dictionary data files especially random access of records by key value. I also would have added more file options and field integrity options as well as the ability to do mathematical manipulations of numeric fields. Also it would have been nice to have been able to split the numeric field into an integer type and a float type rather than one field for both as exists now. The file test2.script shows that its possible to enter the value 0.98 into the social security number field. Funnily enough you could declare a strictly integer field by declaring a character field and then using the character field option onlychars: "0123456789".I would have liked to have added as well either a date option or an actual date type to check for legal dates. Some options are perhaps not as flexible as could be e.g. the option 'nochange.' which doesn't allow you to change a field's value should perhaps only work when editing existing data and not when appending new data to the data file. To do the command line parsing I used the ability to define Command classes in the class diagram and then have an automatic parser be generated. For the most part this worked fine except in instances where an argument to a command was optional and thus entering a newline would not suffice to terminate the command parsing. Here it would be necessary to enter EOF (i.e. CTRL-D). For example the editing command takes a list of fields to edit or no arguments to signify editing of all the fields. Thus to specify you wanted to edit the fields 'id' and 'cd' you would need to specify the command: edit id cd and follow that by a newline and then CTRL-D to terminate the command. (so be warned that if the program 'hangs' after entering a command its probably waiting for a CTRL-D). Another parser problem was in parsing an Ident which would lead to confusion at times when the Ident was in fact the same as syntatic sugar in the class dictionary for example to issue the command help help would be a problem as the second help would be seen as another invocation of the help command. To overcome this I often kept arguments as strings e.g. you would specify in this case: help "help" If the parsing fails you should get a ParseError message telling you what what was expected........... 2 things to remember and that is that when editing a field illegal values are determined by field type and any field data integrity options that might be specified. Data input for field is not parsed by the generated parser instead data errors are detected at the level of the data dictionary field integrity checks. The other is that you must specify a keyfield: option in the data dictionary in order to find something by key value with the find command. Test input and output : _______________________ The files ending in .dd represent the test data dictionaries that the program was invoked on. The test outputs are the equivalent .script file created by using the UNIX script command. In addition there is an EdInit file which loads the names of acceptable commands, the strings by which they are known and help strings invoked by the help command in the editing system. To run you can specify (for example) java gen.Main test.dd from within my project directory. To be able to actually edit and append records to the data dictionary's data file you will need write access. The data file is specified with the file: option in the data dictionary. To do this I would suggest creating a .dd file in a directory where one does have write access and specifying the full pathname of the data file with the file: option e.g. if you created a .dd file in /tmp (e.g. /tmp/test.dd) you would then specify with the file: option in the file /tmp/test.dd the full pathname of the data file e.g. file: /tmp/test.dat and then execute my program (still from my project directory as the file EdInit resides there although I suppose you could copy that as well) by typing: java gen.Main /tmp/test.dd In response to the question as to whether or not Java code was modified directly the answer is no.