how to create database in c++
need your advice what to use.开发者_StackOverflow中文版.. I have a task. Create an application, where u could see the list of current employers, plus buttons remove add employer...
Should I use database or somehow can read just information from file....
If you don't need persistence (information about employers doesn't need to survive between application restarts); keep all employers in memory.
If you've got, let's say, 10000 employers at most, use a text file.
If you've got many more, use sqlite as others have already suggested.
If you've got a few hundred million, use PostgreSQL and a dedicated server if your machine doesn't have enough RAM. Since I really doubt you have that many employers, you can safely skip this step.
If it's homework, you'll probably be able to get away with just a plaintext file. Database will only complicate your task.
One of the greatest advice of programming I could give you is K.I.S.S. (Keep It Simple Silly/Stupid).
Don't raise the complexity of the program unless you need to. Use the most simplest approach that merits the application. Darioo's comment sums it up.
For your purposes, if you need to persist your data then use a text file. The C functions fprintf and fscanf are your friends. Or you can use the C++ streaming functions. A homework assignment does not merit use of a database (which adds extra complication) unless its specifically about using a database API (which I doubt).
Hope this helps.
if project small and local you can use sqllite, if it larg you must think for real db
Find and use sqlite.
It is free, easy to use, cross-platform, and gives you a pretty complete SQL implementation.
Should I use database or somehow can read just information from file....
Programming is a trade-off. You can generally optimize for one:
- Ease of programming
- Robustness
- Scalability
- Cost
- Ease of installation
Furethermore if you're optimizing for ease-programming, for example, then it also depends on what you have already: do you know how how to program with databases? Do you have a database you can use?
For your application, you might use a combination database-plus-UI like Microsoft Access.
精彩评论