CS377: Database Design - File I/O (100 Points)

Assignment Goals

The goals of this assignment are:
  1. To use file I/O to read and process records in a flat file format

Background Reading and References

Please refer to the following readings and examples offering templates to help get you started:

The Assignment

In this lab, you will create and document your own file format for a family tree. You will also write a program to input information and output a family tree file in your format. You will then exchange file formats with a partner, who will write a program to read a file in your format and print the family tree to the screen and generate a dotty graph of the family tree.

File Format Creation

Invent your own file format for a family tree. Be careful to avoid duplicating data within the file. Each person should have a unique identification record number that is referred to elsewhere in the file. The family tree file should include people (with their name, date of birth, and any other information you’d like to include), as well as relationships between family members (parent, child, sibling, etc.).

File Format Documentation

Document your file format thoroughly. This should include a detailed explanation of how the file format works, what each part of the file represents, and how to read and write to the file.

File Writer

Write a program that allows the user to enter information at the console and output a family tree file in your format. The program should be able to take input from the user and create a file in your format that represents a family tree.

Exchanging File Formats and Creating a File Reader

Exchange your file format documentation (but not your code) with a partner. Your partner will write a program to read a file in your format.

Each partner will write a program that can read a file in the other partner’s format, print the family tree to the screen, and generate a dotty graph of the family tree.

Dotty Graph Example

Here is an example of a directed graph in the DOT language. The node names are given in quotes, with their label inside the properties brackets. Then, the edges are defined by specifying two node names with a textual arrow -> between them. Edges can be labeled as well (for example, with the type of relationship between the two people).

digraph family_tree {
    // Define nodes
    "John" [label="John\n(1970- )"]
    "Jane" [label="Jane\n(1972- )"]
    "Alice" [label="Alice\n(1995- )"]
    "Bob" [label="Bob\n(1998- )"]

    // Define relationships
    "John" -> "Alice" [label="parent"]
    "John" -> "Bob" [label="parent"]
    "Jane" -> "Alice" [label="parent"]
    "Jane" -> "Bob" [label="parent"]
}

This graph can be converted to an image using the following command, assuming you have dotty/graphviz installed: dot -Tpng filename.dot -o outfile.png

Reflection

Reflect in your README about how easy or difficult it was to follow the file format documentation, and why. Consider what made the documentation easy or difficult to understand, and how the documentation could be improved. Specifically, answer the following questions:

  1. Discuss with your partner ways that you could improve your own file format. Document those suggestions here.
  2. Why might it be difficult to encode relationships using a text-based format like CSV or json? It’s not impossible - you can do it, but what makes it difficult for you to do?
  3. What are some ways you might use data structures to improve your program’s performance to search and find relationships within your file format? You don’t have to make these changes, just discuss how you might use them, and how you might encode them into your file.

Exporting your Project for Submission

When you’re done, write a README for your project, and save all your files, before exporting your project to ZIP. In your README, answer any bolded questions presented on this page.

Submission

In your submission, please include answers to any questions asked on the assignment page in your README file. If you wrote code as part of this assignment, please describe your design, approach, and implementation in your README file as well. Finally, include answers to the following questions:
  • Describe what you did, how you did it, what challenges you encountered, and how you solved them.
  • Please answer any questions found throughout the narrative of this assignment.
  • If collaboration with a buddy was permitted, did you work with a buddy on this assignment? If so, who? If not, do you certify that this submission represents your own original work?
  • Please identify any and all portions of your submission that were not originally written by you (for example, code originally written by your buddy, or anything taken or adapted from a non-classroom resource). It is always OK to use your textbook and instructor notes; however, you are certifying that any portions not designated as coming from an outside person or source are your own original work.
  • Approximately how many hours it took you to finish this assignment (I will not judge you for this at all...I am simply using it to gauge if the assignments are too easy or hard)?
  • Your overall impression of the assignment. Did you love it, hate it, or were you neutral? One word answers are fine, but if you have any suggestions for the future let me know.
  • Using the grading specifications on this page, discuss briefly the grade you would give yourself and why. Discuss each item in the grading specification.
  • Any other concerns that you have. For instance, if you have a bug that you were unable to solve but you made progress, write that here. The more you articulate the problem the more partial credit you will receive (it is fine to leave this blank).

Assignment Rubric

Description Pre-Emerging (< 50%) Beginning (50%) Progressing (85%) Proficient (100%)
File Format Writer Implementation (30%) The algorithm fails on the test inputs due to major issues, or the program fails to compile and/or run The algorithm fails on the test inputs due to one or more minor issues The algorithm is implemented to solve the problem correctly according to given test inputs, but would fail if executed in a general case due to a minor issue or omission in the algorithm design or implementation A reasonable algorithm is implemented to solve the problem which correctly solves the problem according to the given test inputs, and would be reasonably expected to solve the problem in the general case
Partner File Reader Implementation (30%) The algorithm fails on the test inputs due to major issues, or the program fails to compile and/or run The algorithm fails on the test inputs due to one or more minor issues The algorithm is implemented to solve the problem correctly according to given test inputs, but would fail if executed in a general case due to a minor issue or omission in the algorithm design or implementation A reasonable algorithm is implemented to solve the problem which correctly solves the problem according to the given test inputs, and would be reasonably expected to solve the problem in the general case
Code Quality and Documentation (30%) Code commenting and structure are absent, or code structure departs significantly from best practice, and/or the code departs significantly from the style guide Code commenting and structure is limited in ways that reduce the readability of the program, and/or there are minor departures from the style guide Thorough documentation is given on the file format chosen that is suitable for exchange with a partner for implementation Thorough documentation is given on the file format chosen that is suitable for exchange with a partner for implementation; additionally, a meaningful reflection is given about the experience writing a file reader that conforms to someone else's file specifications
Writeup and Submission (10%) An incomplete submission is provided The program is submitted, but not according to the directions in one or more ways (for example, because it is lacking a readme writeup or missing answers to written questions) The program is submitted according to the directions with a minor omission or correction needed, including a readme writeup describing the solution and answering nearly all questions posed in the instructions The program is submitted according to the directions, including a readme writeup describing the solution and answering all questions posed in the instructions

Please refer to the Style Guide for code quality examples and guidelines.