Book a Demo

Author Topic: Aggregation of Tables  (Read 3446 times)

deboeck

  • EA Novice
  • *
  • Posts: 18
  • Karma: +0/-0
    • View Profile
Aggregation of Tables
« on: April 18, 2005, 09:39:19 am »
Dear,

 How do I "aggregate" two tables ? Adding an aggregation  between two tables does not seem to change the generated DDL.

Thanks,
Bart

thomaskilian

  • Guest
Re: Aggregation of Tables
« Reply #1 on: April 18, 2005, 12:55:00 pm »
Aggregation will let you define foreign keys. You have to define the role then. (Not using EA for DDL generation myself - just telling what I remembered when playing around with it some time ago)

deboeck

  • EA Novice
  • *
  • Posts: 18
  • Karma: +0/-0
    • View Profile
Re: Aggregation of Tables
« Reply #2 on: April 19, 2005, 04:30:20 am »
I've made two tables, Table1 and Table2. Each table contains a primary key. The primary key of Table1 is ref1 and the primary key of Table2 is ref2.
After adding a composition and specifying the Source Role (ref1) and Target Role (PK_Table2), the project view shows a foreign key.
After generating the DDL, I find the following :


-- Drop Foreign Key Constraints
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id('FK_ref1') AND OBJECTPROPERTY(id, 'IsForeignKey') = 1)
ALTER TABLE Table1 DROP CONSTRAINT FK_ref1
;


-- Drop Tables
IF EXISTS (SELECT * FROM dbo.SYSOBJECTS WHERE id = object_id('Table1') AND  OBJECTPROPERTY(id, 'IsUserTable') = 1)
DROP TABLE Table1
;

IF EXISTS (SELECT * FROM dbo.SYSOBJECTS WHERE id = object_id('Table2') AND  OBJECTPROPERTY(id, 'IsUserTable') = 1)
DROP TABLE Table2
;


-- Create Tables
CREATE TABLE Table1 (

ref1 int NOT NULL
)
;

CREATE TABLE Table2 (

ref2 int NOT NULL
)
;


-- Create Primary Key Constraints
ALTER TABLE Table1 ADD CONSTRAINT PK_Table1
PRIMARY KEY (re)
;

ALTER TABLE Table2 ADD CONSTRAINT PK_Table2
PRIMARY KEY (ref2)
;


I do not understand why there is a "drop foreign key constraint" but no "create foreign key constraint". Is anything wrong in my model or is this an EA bug ?
I'm using EA version 4.51.751.

Regards,
Bart

hd

  • EA Administrator
  • EA User
  • *****
  • Posts: 312
  • Karma: +0/-0
    • View Profile
Re: Aggregation of Tables
« Reply #3 on: April 19, 2005, 03:11:24 pm »
For details on creating foreign keys, enter "Foreign Keys" in the EA help index.  :)

deboeck

  • EA Novice
  • *
  • Posts: 18
  • Karma: +0/-0
    • View Profile
Re: Aggregation of Tables
« Reply #4 on: April 19, 2005, 03:19:27 pm »
tanx for your reply
I'm not trying to add a foreign key, luckily I know how to do that  :D, I'm trying to add a composition, you know, the compose arrow in the Toolbox - Structure  ;)
The generated DDL after adding a composition is not ok ...