(Just an aside--is everybody switching to top posting--where's the
context, what's the question--must I read the rest of the post to find
the question? (Sorry, I'm in a funky mood, on another list I read,
some guy quoted a long post, and somewhere in the middle of it posted a
short phrase response (less than a line). What a pain.)
Anyway, after skimming the rest of the post, I'm not entirely sure of
your question:
* do you want pointers on how to search for "sparse tables" on
google, or
* do you want help on storing "variable column sparse tables"--ahh, I
didn't see the variable column part the first time I skimmed
Anyway, before I saw that, I was going to say that a relational data
base (which is what Rails uses (iiuc, something like MySQL, Postgresql
(??), or whatever, is something like a sparse table because tables
don't have to be "complete"--for example, if the key field is some
numerical index, you can have records 001, 006, and 046--you don't have
to have a line for every record from 001 thru 046.
But I guess that's not what you mean by "variable column sparse tables".
So what do you mean? You mean where (starting with my sparse example
above ;-), some records (lines) do not have a value for every column?
Maybe something like this:
View in fixed font:
key lastname firstname height weight hatsize shoesize
001 Mattia Frank 5'11" 7 1/4 10
006 Doe John 5'6" 165
046 Jane 5'5"
If that's what you're looking for, as far as I know, tables like this
can exist in a relational data base and not really cause any problem.
A pedant would (I think) make some comment about the data not being
fully normalized, and maybe some slightly less efficiency that would be
experienced if you had many (i.e., thousands, millions) of such
records.
OTOH, normalizing the database (typically) takes effort both by the
programmer / database administrator and in the database itself (running
queries or whatever to actually accomplish the normalization, so for
small quantities of data (I would argue that) it is not efficient to
normalize the data.
> > afaik i need a table for my rows
> > a table for my columns
> > a table for cells.
> > and a table of "tables"
I haven't thought through what the above is about, but at a quick skim
it sounds like the kind of tables and effort that would be needed to
normalize the database. Like I said, for some definitions of small,
this is counterproductive for small quantities of data (imho).
If your question is something else, maybe you can clarify.
Randy Kramer
--
I didn't have time to write a short letter, so I created a video
instead.--with apologies to Cicero, et.al.
Well, I sort of stand by my original response then. I mean, when you
have an unnormalized relational database and responses are too slow,
the typical recommendation (I think) is to normalize the database. I
won't try to explain that here, you need to look it up. (Maybe someone
can explain it (and how to do it) simply, but I can't, at least not at
this time.)
Normalizing the database is not the only way forward however, and I'd
ask how much data you have. For my only (in progress) application, a
relational database is just not the right fit, and in general slows
everything down (in comparison to plain text files and "ordinary" (and
indexed) searches). (My application has plain text files with
(currently) up to 5000 variable length records per file, totalling on
the order of 10,000,000 characters per file. At them moment I have
about 12 such files, although only two are that big. I plan to scale
to files as big as 100,000,000 characters without switching to a
relational data base (which I'm sure would slow down my application).
How much data will you have in this(these) table(s)? For a low quantity
of data, maybe even a spreadsheet "technology" would do the job?
Other solutions, like a separate machine (server) to handle the database
could help as well. I guess someone would need more information,
specifically about the quantity of data involved (now and in the
future).
OTOH, if this is a rails application, presumably there is a client and a
server (and TCP/IP communication between them)--is the database
processing on the server really the bottleneck?
At least one more comment interspersed below.
On Tuesday 10 February 2009 09:37 am, frankj...@gmail.com wrote:
> ive toyed around with just using txt files but my limited
> understanding of "proper technique" in dealing with them makes them
> just as cumbersome...
>
> im very familiar with normalization and if it was practical (and the
> cost didnt outweigh the benefit) id make sure everything was
> absolutely 6NF and then some... but coulda, woulda, shoulda... its not
> practical.. the best im shooting for is 3NF or 4NF but its not a
> stringent requirement...
>
> i guess you could say i know my way around databases, im just lost
> with trying to implement this in a ruby way. my database breakdown
> will probably look as follows (i think, unless someone can point me in
> a better direction)...
>
> over time there may be 5000 sheets... each sheet may have up to 20
> columns. each column will eventually belong to exactly one group. each
> group may have up to 400 "rows"... .. so if a sheet has 4 columns and
> 2 groups like my prev. example and is filled to capacity... theres
> going to be 400 rows for each set of groups... 800 rows... they need
> to then be translated into one cohesive unit for display. the final
> display will have all 4 columns separated into groups and "merged" so
> all the "toolnumbers" line up in rows.. displaying only 400 rows.
Without a lot more thinking, I don't fully follow the above description.
I guess "sheet" is the first thing that puzzles me--is a sheet a table,
or is there a table containing up to 5000 sheets? (Maybe the "schema"
you list below would answer that and my other questions, but it would
probably take me a while to puzzle it out--more time than I have atm.)
If I really wanted to understand it, I'd ask for an example using "real"
data--sheets, columns, and rows just confuse me (would that be
metadata?).
Good luck!