Miguel Oliveira | 17 Feb 2008 15:05
Picon
Favicon

metastorage: how to set an unique one-to-one relation between two classes

Hello,

I've started using metastorage and create my component to generate  
the db schema:

   <class>
     <name>users</name>

....
    <variable>
      <name>profile_id</name>
      <class>profiles</class>
    </variable>
</class>

also,

   <class>
     <name>profile</name>

....
    <variable>
      <name>user_id</name>
      <class>users</class>
    </variable>
</class>

Webstorage generate the output schema and manipulation files and  
further, metastorage create the db.

My doubt consists in this: When adding a new user record it should  
have an associated profile(mandatory). The fields user_id and  
profile_id in database are not defined as 'not null' as i think they  
suppose to be.

Is in metabase any way to make those fields 'not null'? I've seen  
documentation regarding to references, getreference, setreference but  
i'm not sure if this should be used or not.

Because i'll need to check user settings and access policy, should i  
create functions to get id's in the component?

regards,
miguel

 

Gmane