?
Solved

saving a 3 dimensional array in a file.

Posted on 2008-10-01
6
Medium Priority
?
917 Views
Last Modified: 2012-06-27
My program is a database management for a theatre which needs to have seats as rows and coloumns which makes the two dimension and the third dimension is the day ( cause every day will have different resevation of seats)  i am trying to set up a database in c++ for my program which needs to have a 3 dimensional integer array. written in a file. My program should be able to read the file and load the integers into my 3d array.  I should be able to save the changes made to the array save correctly to the file.  Any idea on how should i create such a file and methods to access it?
0
Comment
Question by:panaz
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 

Accepted Solution

by:
DropHitMedia earned 1500 total points
ID: 22613299
Im not sure how this works in c++ but most array moves to/from dbase would involve converting the array into a character seperated string then back into an array.

But, it seems that you could simply store each reservation, as they are made, in the dbase, then simply include the row, seat and date as data for that record:

UniqID - Date - Row_Col
1 - 12/12/2008 - 1,12

So now you simply have a 2 dim array storing the  Row_col and can insert this by making the array into a comma seperated value before inserting.
Do a search on google for storing arrays in databases which should help.
0
 
LVL 28

Expert Comment

by:Bill Bach
ID: 22619356
This is like the third or fourth request that I've seen on EE for the exact same problem over the last year.  Is everyone working on a new theater software package???

Instead of creating and storing the entire array, which will be wasteful of both memory and disk space, it is probably best to build a single 2-D array by venue to record which seats are available, with a primary key on venue/section/row/seat.  This is important because you can also add more attributes (obstructed view, mezzanine, etc.) to the list to help in pricing decisions.

Add an event table which has a simply ID field as the key, including the event title, date, and other such items.

Then, you can add another table that contains the reservations, with a primary key of event/venue/section/row/seat.  

These tables can be created in any SQL database, including MySQL, SQLServer, Pervasive PSQL, Postgres, Oracle, or others, using standard ADO interfaces for reading and writing the data to/from the files.
0
 
LVL 1

Expert Comment

by:siddhant3s
ID: 22754130
Why dont you guys use classes instead.
Write a class and make a vector (or array) of the object of that class.
Why stick on that primitive array.
Anyways, one way is the to use character identifiers to store data to a text file.
like this
Say you have an array of dimension X by Y by Z
Use three nested loop:

The characters $,# and ! will differentiate between several things.




for(int i=0;i<X;i++)
{    for(int j=0;j<Y;j++)
    {
        for(int k=0;k<Z;k++)
            file<<array[i][j][k]<<'$';
    file<<'#';
    }
file<<'!';
}

Open in new window

0
 

Author Comment

by:panaz
ID: 22934274
sa
0
 

Author Comment

by:panaz
ID: 22934276
asd
0

Featured Post

Get MongoDB database support online, now!

At Percona’s web store you can order your MongoDB database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card. Handle your MongoDB database support now!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question