Daniel Feiglin wrote:
Hello folks!

I have a problem with SQL for MySQL (and pre4sumably any other kind):

Can anone offer a RTFM do do something like this:

create table foo (
    boo    int,
    bar varchar;
    baz array[0..9] of int, # illegal, but needed!
    ...
);

I'm not really thrilled about stuffing all the data into a blob or a varchar and using c/c++/whatever text handling.

Apparently (from my old SQL book), arrays other than of characters, are not supported in standard SQL.

PostgresQL seems to have something like this, see:
http://www.sql.org/sql-database/postgresql/manual/arrays.html
(for those who need yet another reason to switch :-) )

I couldn't find an equivalent of this in MySQL.

Another option would be to split this array field into a separate table
(multiple records associated with table "foo" via a foreign key +
"array index" field). I suspect that this is an example of what's called
"normalization" in database design parlance.
The benefits I see for this are:
1. Unused "array entries" are not allocated.
2. You can take advantage of smart SQL queries to manipulate the array
(e.g. sum, count, max, min, average, sort, compare with "arrays" of
other records, etc...)
3. It's portable across RDBMS implementations.

HTH,

--Amos

=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]



Reply via email to