Re: dia - database sheet



On Mon, Sep 10, 2012 at 7:51 AM, yanf50 <yanf50 yahoo com hk> wrote:
Hi, are the FOREIGN KEY constraints supported?


Yes, but dia2code is a separate closely related project.

Primary key: properties that are class scope. Just set it to class
scope and it will generate a foreign key. It supports multiple-col PK.

FK: Make an association from the owner of the data to the class that
uses the FK. In that direction only. Example:

Person --> Role (Role class references Person class person.id and FK
is named person_id).

1) Select the UML association tool. Click on center of Person (the
owner of the referenced key) and drag it to the center of the Role
class. Name the association person_id. The surrogate key model is
assumed so the Person table has a serial id and the Role table has
person_id.

2) The id on Person should be  class scope

3) Run dia2code -t sql -sqlx fkidx mydiagram.dia

This will generate the DEFINITION.SQL DDL for all tables. Then you
should see the alter for the primary key and and alter for the FK
something like:

ALTER TABLE role ADD
    CONSTRAINT  FK_role_person  FOREIGN KEY(person_id) REFERENCES person (id);


Associations are processed last as ALTERS to avoid dependencies on
tables. So the basic DDL is done first and associations are done last.

The -sqlx fkidx will also create the indexes for the FKs.

You will need late dia2code 0.8.4 or 0.8.5

Best,

-- 
Alejandro Imass

thanks and regards

_______________________________________________
dia-list mailing list
dia-list gnome org
https://mail.gnome.org/mailman/listinfo/dia-list
FAQ at http://live.gnome.org/Dia/Faq
Main page at http://live.gnome.org/Dia





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]