Thread: Should I use vector or list for a database system?

  1. #1
    Registered User
    Join Date
    May 2014
    Posts
    1

    Red face Should I use vector or list for a database system?

    I am making a console based database system. Because I have to keep inserting, editing , deleting data blocks from my record file I have decided to use either vectors or list to store the all records. From the file I shall read the entire vector/list and work with it to add , remove or edit record and then again write the entire vector/list to the file again. I figured it would stop all the weird things that happen when directly working with the file. Is it an efficient way ?Or is it totally unnecessary ?Is there a better way? Thanks in advance !

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by weml
    From the file I shall read the entire vector/list and work with it to add , remove or edit record and then again write the entire vector/list to the file again. I figured it would stop all the weird things that happen when directly working with the file. Is it an efficient way ?Or is it totally unnecessary ?Is there a better way?
    Your idea would be feasible if there are sufficiently few records.

    Is implementing (by yourself) efficient storage, retrieval and other operations for the underlying database system your main concern? If not, I suggest providing a console based front end of your choice for something like SQLite.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    For few records (where you can read everything into memory and back to disk quickly) and where you don't need flexibility of a full database, you might consider simply using a vector, a list or a map and serializing this to disk and back. A good serialization library that supports this easily is cereal.
    If you do need something more efficient, consider using SQLite as a database backend as laserlight suggests. Though I haven't used it, you might want to check out sqlpp11, as well. This is a front-end in C++ for database systems, SQLite among them. It is written in modern C++ with typical C++ idioms.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Changing static array database system to linked list
    By DLH112 in forum C Programming
    Replies: 13
    Last Post: 12-09-2009, 12:50 PM
  2. A database sort of management system
    By relyt_123 in forum C++ Programming
    Replies: 5
    Last Post: 07-01-2008, 03:11 AM
  3. file system vs sql database
    By underthesun in forum C++ Programming
    Replies: 7
    Last Post: 01-05-2008, 02:50 PM
  4. Linux database system needed
    By BobS0327 in forum Tech Board
    Replies: 7
    Last Post: 06-11-2006, 03:56 PM
  5. Making a Simple Database System
    By Speedy5 in forum C++ Programming
    Replies: 1
    Last Post: 03-14-2003, 10:17 PM

Tags for this Thread