Qbasicnews.com

Full Version: database
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
hey i was just wondering if anyone had a program that stored anbd SAVED a simple dtatabase of names and ages or something like that that i could take a look at to learen how to get my databasesw to save, i can get a open command to save using the output or append commands but not the RANDOM command.
How many records, that is names, are you planning to have in your file or database as you call it? If the total number of records is less than say 100,000 then you really can solve the problem with plain old text mode sequential files.

Is your program going to add, change and delete records? Is it also going to be able to display certain records? Is the matching going to be on the name field? Does the name field contain lastname, first name, middle name? Or do you have separte fields fore these? Are you going to allow duplicate names?

Answer these questions and I can show you how to simply do it with out using random nor binary mode files.
*****
yes under 100,000 and it will be able to search and display through the name field. i have a separet last name and first name feild and an age and adrees feild. yes allow duplicate names. thx for the help!!
This is not for some sort of homework, is it?

I'm getting lazy, so I don't want to do all the programming. If I give you specifications, will you handle the code, and post it as well?
*****
no its not homework im trying to learn how to do it, i accualy learned how to do this but in my other thread i cant get it to display and save catagories and also stored them by words not numbers. the last part of what you said i dont understand can you rephrase that plz.
I said: "If I give you specifications, will you handle the code, and post it as well?"

What I meant is if I give you written instructions (specifications), are you willing to do the coding? As I said before, we will be using regular sequential files, no random and no binary.

BTW, I saw your other thread and you're using RANDOM. If you want to do it in random, I can't help you because I've never found a use for it and so I don't know how it works.
*****
yes i am willing :o
Ok, here's the idea.
We'll use sequential text files.
To keep things normal, we will do the following:
* Design each field as fixed length, picking the maximum length.
* Decide which field or fields are going to be the "key". In your case probably the last name field combined with the first name field will be your key field.
* Let's decide now that there will not be any duplicate keys, because that just complicates things.
* So, each record on the file will be fixed length because all the fields are fixed length.
* I would make the first two fields be: last name, then first name. The order of the remaining fields doesn't matter. Just from experience, I would make the last name field be 20 characters, which is plenty, and the first name 15. Therefore, the "key" becomes the first 35 characters of each record.

CREATE THE FILE THE FIRST TIME.
There are two ways you can do this.
1) Key in all you initial (first) records into Notepad, adhering strictly to the size of the fields that you decided. BUT, be very careful that the "keys" of every record are in sequence. Poof, at the end, you have your initial file.
2) Wait until your program is working and then add all the initial records to the file.
I recommend number (1) because you immediately have a file to play with.

Ok, think about all the above, and create your first file (10 or 20 records is fine. When you're done, we'll move on.
*****