Thread: Help designing a "database"

  1. #1
    Registered User
    Join Date
    Jan 2005
    Posts
    204

    Help designing a "database"

    Hi. One of my friends works at his sister's clothing store and about once a week I go over there to chat with him. I noticed they have a serious problem keeping their clients files organized because my friend spends about half an hour looking for a file when someone walks in and buys something or wants to pay something.
    Just for fun, to help him and as a learning experience, I decided to try to write a program. I'm using a filing card they use at the store to base my program on. It has things like name, date, address, city, state, zip and phone number on it. I already got this part done and I validate every single piece of input so this part is really good. I'm also able to create a .clt file with that information on it, but this is where I need your help. How should I set up the files part? What I'm thinking is to create a file for each client and each file will have the clients name, ie John Smith.clt. I think that would be good since my program will have a option for looking for clients files and displaying them. What do you guys think about this?
    Also, they do a lot of selling on credit and people pay like $30 a week and things like that. On the filling card there are also things like quantity, description and price. My other question is, how should I set up this part? Should I ask the user to input the number of items sold and then start a loop where he will input quantity, a little description and the price or should I just enter the loop and wait until he types "done" or something like that? Also, should I keep what a client bought on a different file or with their information? I'll attach the file my program creates and a picture of the filling card so you guys can understand better. Thank you and sorry for the long post.
    Last edited by caduardo21; 02-07-2005 at 07:38 AM.

  2. #2
    former member Brain Cell's Avatar
    Join Date
    Feb 2004
    Posts
    472
    How about you use paragraphs in your post first? I might not be able to help , but you'll make it easier to read.
    My Tutorials :
    - Bad programming practices in : C
    - C\C++ Tips
    (constrcutive criticism is very welcome)


    - Brain Cell

  3. #3
    Registered User xxxrugby's Avatar
    Join Date
    Jan 2005
    Posts
    178
    This is how you can do your file called like your customer name!
    Code:
    #include <stdio.h>
    #include <string.h>
    
    int main()
    {
        FILE *fp; char name[30]; char file[30]; int i = 0;
        printf("Insert name of customer : ");
        scanf("%s", &name);
        strcpy(file, name);
        strncat(file, ".clt", 4);
        fp = fopen(file, "w+");
        fprintf(fp, "Name was %s and file was called : %s", name, file);
        fclose(fp);
        return 0;
    }
    quazah what is your choice or what are you using to get the same input like in gets()
    Last edited by xxxrugby; 02-07-2005 at 04:03 PM.
    Sorry for spelling errors, not English!
    xxxrugby: "All Human Race Will Die From My Hand!"
    xxxrugby: "We are all philosophers, when question is about politics!"

  4. #4
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    You should go look at the FAQ as to why gets is wrong.

    Quzah.
    Hope is the first step on the road to disappointment.

  5. #5
    former member Brain Cell's Avatar
    Join Date
    Feb 2004
    Posts
    472
    without gets() ofcourse.

    *edit* i guess im 2 minutes late
    My Tutorials :
    - Bad programming practices in : C
    - C\C++ Tips
    (constrcutive criticism is very welcome)


    - Brain Cell

  6. #6
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    That's one of the worst "here's my homework" write-ups I've ever seen.

    Quzah.
    Hope is the first step on the road to disappointment.

  7. #7
    Registered User
    Join Date
    Jan 2005
    Posts
    204
    This is not homework. Geez!
    I just need ideas, that is all. I don't want any code

  8. #8
    Registered User
    Join Date
    Feb 2005
    Posts
    12
    Quote Originally Posted by caduardo21
    How should I set up the files part?
    In my opinion, one file per client is a good idea. This will help in getting the client summary/specifics at any point of time very easily. But there can be one master file which will store data about all the clients(their contact details etc as well as their credits). The file with the client name (eg. rjv.clt ) will store the details of purchases datewise.
    Quote Originally Posted by caduardo21
    Should I ask the user to input the number of items sold and then start a loop where he will input quantity, a little description and the price or should I just enter the loop and wait until he types "done" or something like that?
    The more efficient thing (in terms of client interaction) would be to let the user keep on entering details and then press some key when done. Additionally, you should provide for some functionality so that cancel a transaction before commiting it.
    Hope this helps.

  9. #9
    ---
    Join Date
    May 2004
    Posts
    1,379
    >>what is your choice or what are you using to get the same input like in gets()

    fgets()
    dont use scanf for strings

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Designing an MMORPG
    By gamingdl'er in forum Game Programming
    Replies: 63
    Last Post: 12-06-2005, 08:06 PM
  2. Designing a database for a windows program
    By MPSoutine in forum Windows Programming
    Replies: 3
    Last Post: 10-14-2003, 10:10 PM
  3. Designing An Editor
    By QuickSilver in forum C Programming
    Replies: 3
    Last Post: 11-03-2001, 12:12 PM
  4. What is your favourite programming or web designing language?
    By techie in forum A Brief History of Cprogramming.com
    Replies: 9
    Last Post: 10-19-2001, 02:14 PM