Toad World® Forums

Cannot remove keys after delete the relationship...


#1

Hi

I am currently having a problem on removing foreign key, which is created when I use the “Relationship” tool to links 2 tables together. I have set up the foreign key relationship by using “Relationship properties”. After I delete the link between the two tables, the tables still display the field which used to be a foreign key of the other table as a foreign key.

I am wondering if there anyway I could remove that foreign key or it is a bug? I have attached an screen shot about the problem I have.

Please let me know if you want me to explain more.

Many thanks

Chi

foreign key problem.doc (69 KB)


#2

Hello Chi,

Are you sure you deleted the relationship via CTRL+Del?

If you pressed only Delete, you removed only shortcut of the relationship, however the relationship itself still exists in the model.

Please let me know the result.

Thanks.

Vladka


#3

Hi Vladka

DELETE BUTTON ONLY
Yeah I only pressed delete button without holding down control key, I am wondering it anyway I could just remove the relationship(foreign key) from “Attribute Properties” windows as well?

CTRL+DELETE
I just tried to use CTRL+DELETE, it could delete the relationship as well as the foreign key, unfortunately, it still displays a bit different than normal attribute. E.g. it look like the field that has primary key/foreign key after I remove the link by using CTRL+DELETE. Please see the screen shot for more explanation.

Please let me know if you want me to explain more.

Many thanks

Chi
relationship problem.doc (380 KB)


#4

Hello Chi,

You write:After I built a relationship and remove the relationship by using CTRL+DELETE and remove it in Entities/Attribute Properties window.

… “and remove it in Entities/Attribute Properties window.” - Let me ask you what you remove?

Please find attached my document. I’ve taken the same steps as you. See the result.

Let me note that in TDM3, PK from parent entity migrates automatically to child entity when you create a relationship. Also, FK cannot exist without relationship. If there’s a FK in entity, relationship exists. You cannot delete FK without deleting appropriate relationship.

Let me recommend you to watch our instructional movies, e.g. this one at:
http://modeling.inside.quest.com/entry.jspa?externalID=671&categoryID=30

If you have more questions, please feel free to write me back.

Regards,

Vladka

.
delete_relationship.doc (24 KB)


#5

Thanks

I am Sorry about I have mis-read the table : (.

Many thanks

Chi


#6

No problem. I’m happy it’s OK now.

Regards,

Vladka


#7

Hi Vladka

I am sorry, I have some more question about the foreign key. I am wonder if i deleted the relationship by using DELETE (without CTRL+DELETE) then the table/entities I got will still have that foreign key, I am wondering if it is possible to remove the foreign key on “Entities or Attribute properties” windows? E.g. I am able to remove the normal attribute on entities properties table, but not the foreign key attribute. I think it would make life easier, as most of the time user will use delete to remove something rather than CTRL+DELETE. Or need to go to Model Explorer and navigate through the Relationship and remove it there.

Or provide extra features on “Entity properties” windows to delete the foreign key and provide a pop-up message asked about whether you would like to delete the Relationship as well …etc

I am sorry about asking the some question again.

Many thanks

Chi
Message was edited by: Chi

Message was edited by: Chi
foreign key problem 2.doc (218 KB)


#8

Hello Chi,


Introduction

* Shortcuts in TDM3
In TDM3, there’s a great feature (except other more great ones… ) - which is the possibility to display multiple representatives of one object in Workspaces and even in one Workspace.

Please see the Film entity in the sample model.
All Items WS - There’s the Film entity with five attributes and five relationships.
Borrowing WS - There’s the same Film entity with five attributes and only two relationships.

-> As you can see, the view is different but only the view. The Film entity is still the same and must have the same properties and same number of attributes.
In WS, you can see only shortcuts of objects - entities, relationships etc. And you can display them at your convenience, e.g. you can have the Film entity four times in the same WS if you like (four shortcuts of this entity).

* Delete options in TDM3

  1. Delete (Del)
  2. Delete Object (CTRL+Del - will be changed to SHIFT+Del)

Via Delete, you delete only shortcuts in WS.

See the Borrowing WS again. There is not the self-relationship Has More Episodes - its shortcut is not here. - However, the FK attribute FilmID Episodes is here, which is correct. The self-relationship exists in the model and is displayed e.g. in another WS with the Film entity. - The Film entity must have its FK attribute as the relationship exists in the model.

Let’s say you have two shortcuts of the Film entity in one WS. If you like to remove one, simply click Delete.

The Delete Object option means you delete object from model. If you press CTRL+Del, the Has More Episodes relationship will be deleted, including all its shortcuts. The appropriate FK attributes will be deleted automatically too.


I am wonder if i deleted the relationship by using DELETE (without CTRL+DELETE) then the table/entities I got will still have that foreign key.

See the info above. + Let me repeat that relationship cannot exist without FK attribute and vice versa. When you create a relationship, FK attribute is created automatically. When you delete relationship-object from model (ctrl+del), the FK attribute is deleted too.

I am wondering if it is possible to remove the foreign key on “Entities or Attribute properties” windows? E.g. I am able to remove the normal attribute on entities properties table, but not the foreign key attribute.

This is not and will not be possible.

…most of the time user will use delete to remove something rather than CTRL+DELETE.

Yes, I agree. I think users will work mostly with shortcuts of objects while modeling on several WS, and will remove shortcuts of objects more often. Therefore, Delete option is here.

CTRL+Delete will be changed to SHIFT+Delete. For better explanation, it will be the same as when you delete files in Windows. First you put them to the Bin (Delete) and then you remove them completely (SHIFT+Delete).

…need to go to Model Explorer and navigate through the Relationship and remove it there.

Delete options:

  1. Select an object (shortcut of object) in WS and press Delete (also Objects menu | Delete).

  2. In Model Explorer, select a shortcut of an object in the Shortcuts folder | right-click | Delete Item.

Delete Object options:

  1. Select an object (shortcut of object) in WS and press CTRL + Delete (also Objects menu | Delete Object).
  2. From the Model menu, select an object type (e.g. Relationships). Select an object in the opened dialog (Relationships dialog) and click Delete.
  3. In Model Explorer, select an object | right-click | Delete Item.

Or provide extra features on “Entity properties” windows to delete the foreign key and provide a pop-up message asked about whether you would like to delete the Relationship as well …etc

It’s not possible (and will not be) to delete relationship via deletion of FK. Why? - Via one relationship more FKs can be transferred. You want to remove one FK and delete the relationship. However, what about other attributes it transfers?
Also, remember that alternate keys can be created and you can connect parent and child entities via them. What if you want to delete an attribute that is part of the AK?
(See the sample model again | All Items WS | the Is Rated Relationship - there’s an example of AK (Title and Director attributes).)

Chi, I hope it’s much clearer now. However, if you need to ask any questions, write us back.

In any case, please feel free to watch instructional movies in the Library section. I’m sure you will find them helpful.

I am sorry about asking the some question again.

No problem. That’s why our TDM support team is here. - To reply, explain and help.

Regards,

Vladka & TDM