Homework II

Explanations about keys (PK / FK)

PK (primary key) – Unique field or a pair of fields in a table or a file that identifies a record (row in a file). Quite often an integer is used, but it can be any type that is unique. One file or table can only have a single primary key. Each file or table has to have a primary key.

FK (foreign key) – this is used to create relations to other tables or files. If a foreign key matches the primary key in another file or table, then these items are related to each other. One file or table can have multiple foreign keys and they’re not unique (can repeat within).

Foreign key and primary key form a relation between 2 or more files or database tables. A single primary key in one file can be related to multiple foreign items in the second file.

E.g. one person can have multiple children; one receipt can have multiple products; one student can have multiple subject declarations; One person can own multiple properties;

For homework II, you have to compose a program and write a report on it.

This is a part of your final grade!

The task

Homework 2 variants will be given out personally in the lab!

Documentation

  • Title page
  • Declaration of originality
  • Description of the program
    • Program flow
    • How are special cases handled?
    • Function descriptions (purpose, parameters and requirements for the values passed, returns, side effects).
    • Structure descriptions
  • Input and output file structure description (not contents!)
  • Screenshots of the running program in different situations
  • List of references. Things you got from books, the internet and your course mate or friend.

Requirements

  • Actions must be repeatable without exiting the program! (use menu structure)
  • Input data comes from text files. You can choose separators yourself (CSV, TSV, spaces, line changes etc).
  • The data in the files is connected by keys (think of relational databases). There’s a one to many relationship between the files (one student can declare multiple subjects)
  • Each of the data files has at least 10 entries per file.
  • The results of actions are displayed on the screen. Each action should evoke a write to file. This includes non-visible actions like reading files etc- the file should be written in the style of a log file (storing queries, actions).
  • There’s error proofing (files, memory, etc.)
  • If there are any dates, they should be stored in a substructure (nested structure)
  • You must use dynamic memory management instead of fixed arrays (except on buffers). Program must work with a dynamic amount of records – if we add or remove records from the files, it should still work.
  • Text fields within the structures must also be done dynamically (instead of char[], use char*)
  • Structures used should be appropriate for the given task. You can add members to the structure when needed.
  • No memory leaks, wasted or unfreed resources. Use valgrind to check.
  • If the task requires you to modify, add or delete data, the modifications must be written to the data files used by the program. If the program is run again, the updated data must be read in!
  • Careful with the file naming! Make sure that the files you are submitting have the same name that you have in code as the data files.
Just a reminder from earlier
  • The code is divided between meaningful functions..
    If you’ve written a snippet of code with the same purpose twice, you should think about creating a function for that as well.
  • Data must be passed to the functions using parameters only.  You can’t use global variables!
  • Coding style requirements are met, including
    • No magical numbers
    • Only required libraries
    • Header
    • Indentation, spaces, comments where necessary
    • etc.

You can always come and ask us if we think your work follows our requirements.

Deadlines

The second homework is valued at 15p.

To get the highest possible score, You have to follow the coding style and complete the requirements given.

A complete homework must be submitted no later than 24.11.2019

Every week after the deadline removes 1p from the maximum possible score. This countdown is halted at 10p, meaning if you submit 7 weeks late, you can still get up to 10p.

We will only accept Your homework until the end of the contact learning period (20.12.2019). Past that, submitting your homework will not be possible.

If we have questions about the submitted homework or are not sure about the original author of this work, we will grade this with 0p. In this case, the work must be defended.

Bonus points / advanced

It is possible to earn 2 bonus points from the task. The bonus points will be included in the grade calculation.

Late weeks don’t apply for solutions that fulfill the bonus points requirements.

To get the bonus points, the following requirements must also be met in addition to the basic ones:

  • Error proofing
  • Log must include accurate timestamps
  • Good structure, optimal use of code, fast algorithms
  • No memory leaks (http://valgrind.org/). Include proof in the report as copied text from the valgrind output, use a mono-spaced font!
  • Program must be able to work with text fields containing multiple words
  • Files must use a comma or a semicolon as a separator between fields (CSV: https://en.wikipedia.org/wiki/Comma-separated_values)

Submitting Your work

Files required:
  • Documentation (pdf)
  • All of the code files
  • Data files required to run the program

Submitting is electronic only. Follow the file naming convention or we might miss your work or mix it up with someone else’s!

Naming schema: HW2_<firstname>_<lastname>_<studentcode>

Example:

File names: HW2_John_Smith_123456IASB

Submitting is done using moodle: moodle.hitsa.ee/course/view.php?id=13128