Toad World® Forums

Primary and foreign keys from logical to physical


#1

Hi.
There’s something I don’t understand.

I define 2 entities in Logical design (let’s say “users” and “forums”). I use “id” as primary key name for both users and forums.
Hence, I define a many-to-many relationship between users and forums.
When I convert to physical model, I obtain a join table “users_forums”.

The questions are:

  1. How can I obtain “forums_users” instead? I’m using the resulting database with a framework who smartly use the convention “in join tables the two table names are sorted”

  2. I obtain a table with 2 attributes called id, which will obviously break sql rules. Instead, I’d like to have a join tables with, let’s say, “id_user” and “id_forum” or “forum” and “user” or “forum_id” and “user_id” or whatever.

How can I?

Thanks!


#2

A clearer example of this problem is a logical entity with a self-relationship.

For example, suppose you have an entity User(id, name, surname) and you want to define a relationship between Users: you can add a non-identitying relationship between User and itself.

Unfortunately, when you convert the logical model to physical model you get a table User(id, name, surname, id) which is obviously incorrect.

My question is: where can I set the name of the foreign key generated by a logical relationship?

Many thanks


#3

Hello Arialdo,

If you want to change the FK attribute name, edit the attribute (in PER model) and change its caption and name - the Parent Attributes (rolename) feature.

Please see the Help file | Index tab and type ‘parent attribute’.

If you have any questions, please write me back. Thanks.

Regards,

Vladka


#4

Hi Vladka,
thanks for the reply.
Yes, of course in PER model changing the attribute is trivial, but I have to repeat this change manually everytime I convert from LER to PER.
My question was about setting that name in LER.

Is there a way?


#5

Hello Arialdo,

Unfortunately, it is not possible to set the name in LER.
I’m afraid, we don’t have a solution to this problem now. Anyway, we will deal with it - CR # 60 689.

Thanks.

Regards,

Vladka + TDM Team