in reply to Re: 3Re: Class::DBI has_a relationships
in thread Class::DBI has_a relationships

Seems to me that your relationships are a bit off. At first i thought that Sessions_Metadata was a cross reference between Users and Sessions. But it is not. Instead, it is extra info for a session. Now, if this were my project, i would only have two tables: Users and Sessions. It seems to me that everything in Sessions_Meta data relates to a session, therefore, why not just put those attributes in the Sessions table?

sessions
   Column    |          Type          | Modifiers 
-------------+------------------------+-----------
 id          | character(32)          | not null
 a_session   | text                   | 
 username    | character varying(40)  | 
 create_date | character varying(100) | 
 expire      | character varying(100) | 
 query_id    | character varying(50)  | 
It will greatly simply your task. Also ... why are you using a character type for the primary key? You should be using an "auto-incremented" integer, preferably unsigned. Likewise, you should also be using the same for your primary key in the Users table.

UPDATE:
I think that is correct, CassJ.

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)

Replies are listed 'Best First'.
Re: 5Re: Class::DBI has_a relationships
by CassJ (Sexton) on May 18, 2004 at 18:03 UTC
    It's not my DB. I don't know anything much about DB design, so I was just using what I was given. I don't see any reason why we sessions and sessions_metadata couldn't be merged though.
    I'll give it a go with my local version (might take a while!).

    If I do that then I'll have just a sessions table with a FK to users - right?

    So Sessions.pm

    has_a(username=>'Users')
    and Users
    has_many(sessions=>[Sessions=>'username']=>'username)
    Does that sound right?

    Cxx