Database assignment is Killing me!

This is a discussion on Database assignment is Killing me! within the C Programming forums, part of the General Programming Boards category; Ive been given this assignment to do, and I have no idea how to go about it. Unluckily the coin ...

  1. #1
    Registered User
    Join Date
    Nov 2007
    Posts
    4

    Database assignment is Killing me!

    Ive been given this assignment to do, and I have no idea how to go about it. Unluckily the coin toss gave me module B to do which is the hardest!

    Module B

    Overview:

    This module performs the storage and retrieval of all records. The records reside in memory only. On demand, data are passed back to the user-interface module for display.

    This module implements only the records database, not user interface.



    Module B Application Programming Interface (API):



    Module B should provide the public routines specified below. These routines must not use the user interface in any way except in case of debugging. Nothing else is acceptable.

    In addition:

    Module B must use one file of code only named: database.c

    All function prototypes for module B must be declared in a header file database.h, so that userInterface.c can include this.





    The following definition must be also provided in database.h:





    Code:
    typedef struct {
    
         char surname[21],   /* student surname  */
    
         char firstname[21], /* buffer to receive message */
    
         char studentID[7],  /* student identifier */
    
         int  studentAge     /* age of student in years */
    
         } STUDENT_RECORD;



    Public routines:

    studentRecordNew( )
    NAME
    studentRecordNew ( ) create a new student record

    SYNOPSIS
    Int studentRecordNew
    (STUDENT_RECORD * studentRecord ; /* IN: the data for the new record */)
    DESCRIPTION
    This routine creates a new student record in the database. It checks if the student already exists.

    RETURNS
    True: if a new record is created.
    False: if student ID already exists. No record is created.


    studentRecordUpdate( )
    NAME
    studentRecordUpdate ( ) update a new student record

    SYNOPSIS
    Int studentRecordUpdate
    (STUDENT_RECORD * studentRecord ; /* IN: the update data */)
    DESCRIPTION
    This routine updates a student record in the database. It checks if the student already exists. Any parameters that are set will be used to update the record. Unused string parameters must be set to the empty string '\0'. Unused studentAge parameter must be set to -1.

    RETURNS
    True: if the record is updated.
    False: if student ID does not exist or any other problem occurs.





    studentRecordGet( )
    NAME
    studentRecordGet ( ) returns a student record

    SYNOPSIS
    Int studentRecordGet
    (char * studentID; /* IN: id of record to be retrieved */
    STUDENT_RECORD * studentRecord ; /* OUT: the student record data */)
    DESCRIPTION
    Takes as input parameter a possible student ID. The routine checks whether the student exists. If the student exists then the routine returns the data in parameter studentRecord. This function can be used to get the data or just to check that a student exists.

    RETURNS
    True: if the student exists in the database.
    False: if student ID does not exist.

    studentRecordDelete( )
    NAME
    studentRecordDelete( ) deletes a student record from the database

    SYNOPSIS
    Int studentRecordDelete
    (char * studentID; /* IN: id of record to be deleted */)
    DESCRIPTION
    Takes as input parameter a possible student ID. The routine checks if the student exists. If the student exists then the routine deletes the student from the database.

    RETURNS
    True: if the deletion is successful.
    False: if student ID does not exist.
    I would really apreciate any help you can give me. My problems are mainly:

    I have no idea what should go in the header file and
    How to store the records (array? etc)

  2. #2
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,536
    The first is easy: all your declarations go into your header file. Functions, structs (some defines too), etc. The rest goes in your .c file.

  3. #3
    Registered User
    Join Date
    Nov 2007
    Posts
    4
    Ok, Ive written my header file (I think), so that problem should dissapear

    Code:
    //typedef code already given
    typedef struct {
    	char surname[21];
    	char firstname[21];
    	char studentID[20];
    	int studentAge;
    } STUDENT_RECORD;
    
    //declaring of functions
    
    int studentRecordNew (STUDENT_RECORD* studentRecord);
    int studentRecordUpdate (STUDENT_RECORD* studentRecord);
    int studentRecordGet (char* studentID, STUDENT_RECORD* studentRecord);
    int studentRecordDelete (char* studentID);
    
    #define TRUE 1
    #define FALSE 0

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  2. Creating a database
    By Shamino in forum Game Programming
    Replies: 19
    Last Post: 06-10-2007, 01:09 PM
  3. Replies: 1
    Last Post: 10-27-2006, 01:21 PM
  4. Replies: 10
    Last Post: 05-18-2006, 11:23 PM
  5. Making a Simple Database System
    By Speedy5 in forum C++ Programming
    Replies: 1
    Last Post: 03-14-2003, 09:17 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21