Re: foreign key as primary key

Franck Routier <[email protected]> Fri, 18 Dec 2009 16:04:54 +0100
Newsgroups gmane.comp.java.orm.simpleorm
Organization Axège sarl
Message-ID <1261148694.7899.7.camel@franck-laptop>
Hi,

as Anthony pointed it Payroll is a good example.

You won't use the SFieldReference itself as part of the empoyee's pk,
but will use the SFieldScalar used in the reference as part of the pk.

eg :

class Department extends SRecordInstance {
(...)
public static SFieldString deptid = new SFieldString(meta, "deptid",
SPRIMARY);
(...)
}

class Employee extends SRecordInstance {
(...)
public static SFieldString emp_deptid = new SFieldString(meta, "deptid",
SPRIMARY);
public static SFieldString empid = new SFieldString(meta, "empid",
SPRIMARY);
(...)
public static SFieldReference<Department> dept = new
SFieldReference<Department>(meta, Department.meta, new
SFieldScalar[]{emp_deptid}, new SFieldScalar[]{Department.deptid});

}


HTH

Franck


Le vendredi 18 décembre 2009 à 17:29 +1000,
[email protected] a écrit :
>   
> Just mark the referencing columns as part of the foreign key. Under
> Franck's simplification there is no longer any nesting of foreign
> keys. Have a look at payroll.java.
> 
> Anthony
> 
> At 04:45 PM 18/12/2009, you wrote:
> > 
> >
> >Hello!
> >
> >How do i define a foreign key as a part of the primary key?
> >For the Empoyee-example this would mean the reference to the
> department
> >would be part of the primary key of employee.
> >Thank you in advance.
> >
> >Ciao, Guenter
> >
> >
> 
> Spreadsheet Detective,
> Southern Cross Software Queensland Pty Limited
> 54 Gerler Street
> Bardon, Queensland 4065, Australia.
> 
> Email: [email protected]
> www.SpreadsheetDetective.com
> Ph: +61 427 830248 (Australian Eastern Standard Time)
> 
> "If the model seems correct only because the numbers look right, 
> then why build the model in the first place?"
> 
> 
> 
> 






------------------------------------

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/SimpleORM/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/SimpleORM/join
    (Yahoo! ID required)

<*> To change settings via email:
    [email protected] 
    [email protected]

<*> To unsubscribe from this group, send an email to:
    [email protected]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/