It's seems that EOM can't model FK with more than one attributes..
So the previous question (if create two-attributes PKs) is answered... I'll create very simple PK with one attribute of type id (sigh..)


On 30/nov/08, at 08:56, Francesco Romano wrote:

Ok.. maybe it's a bit better...

this are the two entities:

ProdottoPrivato
<Picture 1.png>

Prodotto
<Picture 2.png>


Prodotto owns and propagate the PK to ProdottoPrivato...

Now.. I've a doubt...Prodotto has its own PK and the key of the entity MERCEOLOGIA. So.. prodotto propagates the key...?? both? (maybe now I've a problem with the theory... if prodottoID is a field ID (a serial) does make sense to have a foreign primary key? In my theorical point of view I thought something like:
MERCEOLOGIA PK     |     Prodotto ID
        1                                          1
        1                                           2
        2                                           1

but I don't think the db do something like that... Am I right? The dbms continue to increment the prodotto_id?


Now...  the last two questions...
1) It's better to have a PK with the two fields (strings) OR a PK of type id and add a unique index on the 2 attributes? (performance, etc..) 2) About inverse relationship... this are saved only in the class graph, not in the db ? I checked a one-to-many relation... even if in the migration the "n" entity has a FK to the "1" entity, it doesn't have it in the db. So.. How does it work? I thought migration was the "interface" to the db...


Thanks
Francesco

On 29/nov/08, at 22:15, Miguel Angel Torres Avila wrote:

Hi Francesco

This an example of a mandatory one to one relationship, for any prodotto it is obligated to generate a PRODOTTOESTERNO.

First you should select the owner entity, I mean the principal one. And I suggest the use of ID's like prodotto_id instead just id.

PRODOTTO
prodotto_id     PRIMARY KEY NOT NULL,
descrizione
referenza
prezzo          
foto                    


PRODOTTOESTERNO
prodotto_id REFERENCES PRODOTTO ON DELETE CASCADE PRIMARY KEY NOT NULL
qtaIniziale
note


In the modeler you should create a relationship from PRODOTTOESTERNO to PRODOTTO connecting PRODOTTOESTERNO. prodotto_id to PRODOTTO. prodotto_id.
The rules in modeler should look like this:

<Picture 2.png>

Now create a new relationship from PRODOTTO to PRODOTTOESTERNO and the rules should look like this.

<Picture 3.png>


Now create your java Classes and Prodotto will have a PRODOTTOESTERNO() function and PRODOTTOESTERNO will have a PRODOTTO() function. This way you will create a new Prodddotto's object and once you insert it into an Editing Context the ProdottoEsterno related to it will be created automatically.

Hope this helps.




On Nov 29, 2008, at 1:23 PM, Francesco Romano wrote:

Hi...
I'm having some problems passing from the "teorical" ER model , to design the real model using EOModeller.

Using the Entity-Relationship model I designed the following tables:

MERCEOLOGIA (nome,marca)
PRODOTTO (id,descrizione, referenza, prezzo, foto )
LUOGO (nome)
PRODOTTOESTERNO (PRODOTTO, qtaIniziale, note)
DISPONIBILITA (PRODOTTO,descrizione)
LUOGO-PRODOTTO (luogo, prodotto, quantita)

Where: the uppercase word is the Entity, between the brackets there are the attributes. The underlined words are the Primary Keys.

So..
MERCEOLOGIA has a 1-to-many relation with PRODOTTO, with the PK of PRODOTTO is id and the PK of MERCEOLOGIA
LUOGO and PRODOTTO has many-to-many relation (plus an attribute)
PRODOTTOESTERNO has a one - to-one relation with PRODOTTO. The PK of PRODOTTOESTERNO is the PK of PRODOTTO
DISPONIBILITA has a one-to-many relation with PRODOTTO.

I've no problem if EOM create a "id" PK for every entity.. I add a Unique key on my "teorical" PK and solve this problem...

but...

I don't know how to create one-to-one relations (I can't add them using the button..) and how to model the "foreign" PK..

Can somebody please help me solving this?

Thanks
Francesco

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/miguel%40toracom.net

This email sent to [EMAIL PROTECTED]

<Firma.png>

_______________________________
Ing. Miguel Angel Torres Avila






 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to