I have a project where I want an offline Database to store a ranking list that doesnt delete itself when turning the arduino off.
I have no problems programming it, I just dont know how to make the offline Database.
Is there a way to use a SD card for that and if yes, how can I do this?
A database can just be a simple text file or a fixed length record file. I think once you have worked out what you need as functionality for this database, you will find that the SD management libraries (like SDFat or the built-in Arduino SD library) will probably be enough. These allow file management and read/write access to data on the SD card.
You ask about a "database" which implies some type if indexing and random access to the record you wish. Please confirm you want a database or you want a file storage.
Technobabble. If you want to store data, SD can do it. The data logging example included in the IDE is probably all you need. There are also means to enter data directly into Excel - no SD required.
Thank you for your replies.
I want to make a local ranking list of a minigame which i designed with an arduino. Meaning I also want to insert some entrys and get random access to all entrys (I asume that is meant by "random access" I'm nut sure).
oopsy:
Thank you for your replies.
I want to make a local ranking list of a minigame which i designed with an arduino. Meaning I also want to insert some entrys and get random access to all entrys (I asume that is meant by "random access" I'm nut sure).
Absolutely means "random access". It also means random read and write of records. It also means you need and index file of the keys and record pointers you want to use randomly.
Your questions suggestion you have no experience with data files, either sequential or random.
Paul
I only have a bit of experience. I already programmed a database once on PC (C++) that stores pointers of objects and can read/write its attributes into a .txt file. Im just not very famililiar with the terms.
Can you explain briefly what you mean with "index file of the keys and record pointers" ?
I only have a bit of experience. I already programmed a database once on PC (C++) that stores pointers of objects and can read/write its attributes into a .txt file. Im just not very famililiar with the terms.
Can you explain briefly what you mean with "index file of the keys and record pointers" ?
Thank You!
i suspect what you did on a PC was to utilize pre-existing software that did all the actual record storage and accessing. Here we are talking about doing all the fundamental basic work.
You begin with creating a file with fixed length records. Each record must have a unique identification as part of the record. I am most familiar with bank checking account numbers, Guaranteed to be unique.
At the same time, a separate file, called the index file, also fixed length records. Each record has the unique identifier you have in the data file record, plus the record number of that data file record.
The data file records do not have to be in any particular order. But the index file MUST be maintained in ascending order of the unique identifier. When you add one data file record, you add a corresponding index file record.
But, after you add any index file record, you must maintain the ascending order of the keys in that file! That may require sorting the file, or copying the file, record by record, adding the new key record at the appropriate location, and then replace the old key file with the newly created file.
Programs that use the files to find any random data record must search the index file for a match to the identifier and use the location of the data record to read the data record.
You soon run out of memory on a small Arduino.
Hope that helps. This scheme was used for many years on both main-frame and mini computers.
Paul
i suspect what you did on a PC was to utilize pre-existing software that did all the actual record storage and accessing. Here we are talking about doing all the fundamental basic work.
I actually programmed everything myself, I spent 2 weeks on an exercise about this at an internship at a software company. I know how to read/write records from files (at least in C++, I'm sure I'll figure out how to use the Arduino Library for SD-Cards) but don't have expertise on this topic and therefore dont know the used procedures in 'real' applications.
For the identification number of a record I used a static variable in the database class that just counts up on every newly added record which guarantees a unique number.
Thank you for your explanation, this helped me a lot to get back into the topic and understand it even better. I think with this knowledge I now know what to do.
I think I will restrict the number of entrys to the size of the SRAM of the arduino. My plan is that the program will create an object of every entry listed in the SD-Card file at the start. This way I have all entrys in the intern SRAM storage at run time and can display them on a local dispay. When there is no more space, a new entry on the ranking list will only enter the database if its value is better than the last on the ranking list.