473,385 Members | 2,004 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Arrays & storage.....

Hi

I have few questions in realtion to arrays, I assume that
they are not available as a data type, is this correct ?
The reason why is that I want to store a large amount
of data for a paticular record and a bit concered about the
size of record. (I assuming that an array of 1000 ints will be
smaller than 1000 records of
table dailyclose ( varchar Symbol, int beta ). Is this a fair
assumption ? (I'm not actually concerned with seek time
but rather the physical record size)
Is there any way around my problem or is it time to optimise my
directory structure to ensure that I can large systems.

Thanks
David
Jul 20 '05 #1
2 1770
LeTubs wrote:
I have few questions in realtion to arrays, I assume that
they are not available as a data type, is this correct ?


I believe that is correct. I find no mention of array column types in
the MySQL documentation. FWIW, arrays are not standard SQL data types,
they are extensions offered in some RDBMS implementations.

One workaround would be to store an array in a BLOB column, and leave it
up to your application code to store the array correctly and to fetch it
correctly. But this wouldn't be SQL support for arrays because you
probably can't fetch an individual array element in a SELECT, or update
an individual array element in an UPDATE, or reference individual array
elements in conditions.

Defining a one-to-many table to store each of the 1000 ints per record
would cost more storage space, because you'd need a foreign key field
referencing the parent table. This would add up quickly if you have
many records. Still more space would be required if you also need to
note the position in the array for each element; that is, if the order
of the elements is important. I infer from your example that you'd need
to record the close date for each element:
CREATE TABLE dailyclose (
VARCHAR symbol(20) # =< 1+20 bytes
REFERENCES stock_or_fund(symbol),
INT beta, # 4 bytes
DATE close_date # 3 bytes
);

On the other hand, hard disks are amazingly inexpensive these days, and
buying a new 120GB disk might be cheaper than the amount of extra
programming time it would cost you to work around the lack of array
support in SQL. ;-) There's sometimes a tradeoff between storage
expense, computational expense, and code development expense. Don't get
too focused on just one of these and ignore the others!

And another advantage of the one-to-many table is that you aren't
constrained to 1,000 entries; it can keep growing to as many entries as
you have data for. Also, doing slices for a given calendar year or
other conditions would be pretty easy, since you'd have a DATE field.

Regards,
Bill K.

Jul 20 '05 #2
LeTubs wrote:
The reason why is that I want to store a large amount
of data for a paticular record and a bit concered about the
size of record. (I assuming that an array of 1000 ints will be
smaller than 1000 records of
table dailyclose ( varchar Symbol, int beta ). Is this a fair
assumption ?


You could try it to see which is larger, but I would suggest you to add
data into several rows, instead of putting it all into one row.

Benefits:
- Faster search is perhaps not needed now, but when it is needed, person
to implement that, doesn't need to learn ancient curses to curse you. (
I have seen this in my work. )
- Database structure is much more clear for others to read and see how
it works. This is the first thing you should think of, and only make
more complex structure if it is really needed.

And benefits if putting all data into single row(s):
- AFAIK there is no array-type in MySQL. So you would have to save
integers in a binary format. I can almost promise that that would take
less space on hard drive, I would guess that 20% of disk space would be
saved, but you really should test this to get better results.

(Assuming that data would be saved in binary format with only numbers in
data, no separators. And assuming int is 4 times larger than varchar.
And assuming that table structure would contain no indexes and each row
would only take as much space as the data needs, no more.)
Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: csx | last post by:
Hi everyone! two quick questions relating to arrays. Q1, Is it possible to re-assign array elements? int array = {{2,4}, {4,5}}; array = {2,3}
5
by: Gent | last post by:
I have two questions which are very similar: Is it possible to return an object in C++. Below is part of my code for reference however I am more concerned about the concept. It seems like the...
11
by: truckaxle | last post by:
I am trying to pass a slice from a larger 2-dimensional array to a function that will work on a smaller region of the array space. The code below is a distillation of what I am trying to...
1
by: Nathan Gilbert | last post by:
I have a function that is returning a 2D array (declared using double pointers) and I want to be able to append a row of data to the beginning and end of this array without having to create a new...
32
by: santosh | last post by:
In following code char str = "asdf" ; str = 's' ; is possible. But char *str = "asdf" ; str = 's' ; is an run-time error. What i understand is *str = "asdf" is stored in Read-only-Memory....
6
by: Broeisi | last post by:
Hello, I wrote the tiny progam below just to understand arrays and strings better. I have 2 questions about arrays and strings in C. 1. Why is it that when you want to assign a string to an...
39
by: Martin Jørgensen | last post by:
Hi, I'm relatively new with C-programming and even though I've read about pointers and arrays many times, it's a topic that is a little confusing to me - at least at this moment: ---- 1)...
41
by: Rene Nyffenegger | last post by:
Hello everyone. I am not fluent in JavaScript, so I might overlook the obvious. But in all other programming languages that I know and that have associative arrays, or hashes, the elements in...
2
by: Dr Dav | last post by:
Hello all, I'm a physicist whose rewriting a numerical simulation, previously written in IDL, in C with the goal reducing runtime. As you may imagine, my C programming skills are quite poor but I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.