Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • Oh, good point. Is something like PostgreSQL's array type the proper solution here then?

    create table sometable (
       id serial,
       name varchar(50),
       email text[]
    );

    This would store a list of email addresses as a single object. Or have I missed the point again?

    In other news, I'm surprised PostgreSQL doesn't have an "email_address" type. It seems to have everything else.

    • How do you then update, insert, delete, or search for a single email address? If it makes things more complicated to deal with the data, I think I'd rather normalize. Hmm, looking at the postgres docs, searching for a value in an array:
      SELECT * FROM sal_emp WHERE pay_by_quarter[1] = 10000 OR
                                  pay_by_quarter[2] = 10000 OR
                                  pay_by_quarter[3] = 10000 OR
                                  pay_by_quarter[4] = 10000;
      But that can be abreviated to (especially when you don't know how many elements there are):
      SELECT * FROM sal_emp WHERE 10000 = ANY (pay_by_quarter);
      But they offer this advice:
      Tip:  Arrays are not sets; searching for specific array elements may be a sign of database misdesign. Consider using a separate table with a row for each item that would be an array element. This will be easier to search, and is likely to scale up better to large numbers of elements.
      • The problem with CRUD on a single email address goes away if you have a language which supports that. SQL does not. While I confess that I don't remember my UniQuery (the query language for the MV database I used), imagine something like this:

        DELETE email
        FROM   customer
        WHERE  name  = ?
          AND  email = ?

        In other words, DELETE would operate on more than just tuples.

        How about searching for a particular email? Well, you show some sample syntax above.

        There are plenty of oth