473,806 Members | 2,787 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to implement a large 2-d array ?

Hello, I'd like to implement a large 2-d array

2d array size: 5000 x 5000
each element: int 4 bytes
type: static, MYISAM
how is this done in MySQL? I'm a newbie, so details will help.

Mike

Jul 23 '05 #1
4 1633
On 29 Jan 2005 21:45:02 -0800, in mailing.databas e.mysql "siliconmik e"
<si*********@ya hoo.com> wrote:
| Hello, I'd like to implement a large 2-d array
|
| 2d array size: 5000 x 5000
| each element: int 4 bytes
| type: static, MYISAM
| how is this done in MySQL? I'm a newbie, so details will help.


Maybe:

CREATE TABLE `tblArray` (
`fRow` int(11) NOT NULL default '0',
`fCol` int(11) NOT NULL default '0',
KEY `IDXrow` (`fRow`),
KEY `IDXcol` (`fCol`)
) TYPE=MyISAM;

Then use:
select * from tblArray where fRow=' + myRow + ' and fCol=' + myCol;
---------------------------------------------------------------
jn******@yourpa ntsyahoo.com.au : Remove your pants to reply
---------------------------------------------------------------
Jul 23 '05 #2
Jeff North wrote:
| 2d array size: 5000 x 5000
| each element: int 4 bytes


CREATE TABLE `tblArray` (
`fRow` int(11) NOT NULL default '0',
`fCol` int(11) NOT NULL default '0',
KEY `IDXrow` (`fRow`),
KEY `IDXcol` (`fCol`)
) TYPE=MyISAM;


One should add a field for the data at a given array element. And
presumably one would want a 2-d array per record of another table, so
one should add a foreign key referencing the parent table.

CREATE TABLE `tblArray` (
`fRow` int(11) NOT NULL default '0',
`fCol` int(11) NOT NULL default '0',
`elementData` integer,
`parentRef` integer not null references parentTable(pri maryKey)
KEY `IDXrow` (`fRow`),
KEY `IDXcol` (`fCol`)
) TYPE=MyISAM;

Then you could fetch the array as follows:

select fRow, fCol, elementData
from parentTable P inner join tblArray A on P.primaryKey = A.parentRef

You can fetch totals by column as follows:

select fCol, sum(elementData )
from parentTable P inner join tblArray A on P.primaryKey = A.parentRef
group by fCol;

See also chapter 23 of "SQL for Smarties" by Joe Celko. He talks about
storing and using array structures in SQL databases.

Regards,
Bill K.
Jul 23 '05 #3
"Jeff North" <jn****@bigpond .net.au> wrote in message
news:db******** *************** *********@4ax.c om...
| 2d array size: 5000 x 5000

Maybe:

CREATE TABLE `tblArray` (
`fRow` int(11) NOT NULL default '0',
`fCol` int(11) NOT NULL default '0',
KEY `IDXrow` (`fRow`),
KEY `IDXcol` (`fCol`)
) TYPE=MyISAM;

Then use:
select * from tblArray where fRow=' + myRow + ' and fCol=' + myCol;


Maybe a Key for the fRow and fCol combined will speed up even more?

Wouter
Jul 23 '05 #4
On Mon, 31 Jan 2005 08:58:21 +0100, in mailing.databas e.mysql "Wouter"
<no*****@no.mai l.for.me> wrote:
| "Jeff North" <jn****@bigpond .net.au> wrote in message
| news:db******** *************** *********@4ax.c om...
| >>| 2d array size: 5000 x 5000
| > Maybe:
| >
| > CREATE TABLE `tblArray` (
| > `fRow` int(11) NOT NULL default '0',
| > `fCol` int(11) NOT NULL default '0',
| > KEY `IDXrow` (`fRow`),
| > KEY `IDXcol` (`fCol`)
| > ) TYPE=MyISAM;
| >
| > Then use:
| > select * from tblArray where fRow=' + myRow + ' and fCol=' + myCol;
|
| Maybe a Key for the fRow and fCol combined will speed up even more?


Wouter and Bill, I agree with both of your excellent suggests but the
OP didn't give many details to work on :-(
---------------------------------------------------------------
jn******@yourpa ntsyahoo.com.au : Remove your pants to reply
---------------------------------------------------------------
Jul 23 '05 #5

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

Similar topics

2
4180
by: Developwebsites | last post by:
const int MAX=999; class person { protected: char firstname, lastname; int ID; public: person();
4
1343
by: fivelitermustang | last post by:
Essentially what the program needs to do is split apart a large group of data and then it further splits apart the groups of data, etc... For example, Level 0 starts off with a large array data. The data is split apart into "n" groups. Then each group in there is also split apart into "n" groups and it continues on like that. For each branch of data the matrix is " Here is a quick picture I drew to illustrate what I'm doing:...
13
2716
by: Sherif ElMetainy | last post by:
Hello I was just got VS 2005 preview, and was trying generics. I tried the following code int intArray = new int; IList<int> intList = (IList<int>) intArray; it didn't compile, also the following didn't compile
5
2723
by: apm | last post by:
Any and all: Is there an efficient way to pass a large array from .NET to COM? Can references (or pointer) be passed from COM to NET and NET to COM without the object it refers to being copied? Thanks in advance. David
5
19604
by: Stacey Levine | last post by:
I have a webservice that I wanted to return an ArrayList..Well the service compiles and runs when I have the output defined as ArrayList, but the WSDL defines the output as an Object so I was having a problem in the calling program. I searched online and found suggestions that I return an Array instead so I modified my code (below) to return an Array instead of an ArrayList. Now I get the message when I try to run just my webservice...
3
4171
by: meltedown | last post by:
Normally, if I use $result=print_r($array,TRUE); print_r prints nothing and $result is equal to the readable array. However, if $array is very large, print_r prints the array and returns nothing. Is this correct ? I don't see anything about this in the the manual. I have tried limiting the size to array to see exactly how large the
7
21266
by: ultr | last post by:
I need a large 3D array of structures: struct s { char a; int b; }; s s_array; s_array is declared as global.
10
5894
by: Peter Duniho | last post by:
This is kind of a question about C# and kind of one about the framework. Hopefully, there's an answer in there somewhere. :) I'm curious about the status of 32-bit vs 64-bit in C# and the framework classes. The specific example I'm running into is with respect to byte arrays and the BitConverter class. In C# you can create arrays larger than 2^32, using the overloaded methods that take 64-bit parameters. But as near as I can tell,...
1
2147
by: parvtb | last post by:
I know STL vector works. But in case STL is not available, what can one do to allocate large memory size in c++ through operator "new"? For instance, I am writing a sort algorithm, and here's part of the code: const int range = 1000000; int *array = new int(range); if (array == 0) cout<<"null ptr returned"<<endl;
0
9719
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9599
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10624
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10371
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10111
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6877
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5546
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5684
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3853
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.