Toad World® Forums

Different Foreign Keys question -- Dates

As you can see in the pic of a demo model of MSSQL08, I have a parent with two PKs (wrkr_id, from_dt) and a child with one PK (wrkr_sys_cd_id) and one actual FK (wrkr_id). You will see that TDM thinks that I want my from_dt as part of the FK in the child. I do not. We do not do an equal join on the key dates but a between in the where clause based on a target date.

How can I get TDM 3.6.6.7 to do both the proper PKs at the parent and the proper FK at the child? Thanks.

FK Model Problem.png

I forgot to add: Could someone tell me why TDM doesn’t automatically select an existing column when adding a child relationship if the names match (and not already in use, etc)? I’m hoping there is an overlooked or hidden option.

Hi,

I believe number of FK attributes in child table should match the number of PK attributes in parent table, if you use PK for the relation.

What about trying to make another key (alternate key) in parent table, add only one attribute to it and then link the relation via the alternate key?

See screenshots.

RE automatic recognition of FK attributes: Toad Data Modeler doesn’t try to map PK to existing attributes in child entities, but you can try the Infer Relationship macro (accessible via menu Macros | All | Infer relationship).

If it doesn’t help, use Foreign Key Mapping. More info about FK Mapping can be found in Help in section Model | Physical model | Entity Relationship Diagram | Keys | Foreign Keys | FK Mapping.

Regards,

Vaclav
messages-005.png

Hi,

I believe number of FK attributes in child table should match the number of PK attributes in parent table, if you use PK for the relation.

What about trying to make another key (alternate key) in parent table, add only one attribute to it and then link the relation via the alternate key?

See screenshots.

RE automatic recognition of FK attributes: Toad Data Modeler doesn’t try to map PK to existing attributes in child entities, but you can try the Infer Relationship macro (accessible via menu Macros | All | Infer relationship).

If it doesn’t help, use Foreign Key Mapping. More info about FK Mapping can be found in Help in section Model | Physical model | Entity Relationship Diagram | Keys | Foreign Keys | FK Mapping.

Regards,

Vaclav
messages-003.png

Hi,

I believe number of FK attributes in child table should match the number of PK attributes in parent table, if you use PK for the relation.

What about trying to make another key (alternate key) in parent table, add only one attribute to it and then link the relation via the alternate key?

See screenshots.

RE automatic recognition of FK attributes: Toad Data Modeler doesn't try to map PK to existing attributes in child entities, but you can try the Infer Relationship macro (accessible via menu Macros | All | Infer relationship).

If it doesn't help, use Foreign Key Mapping. More info about FK Mapping can be found in Help in section Model | Physical model | Entity Relationship Diagram | Keys | Foreign Keys | FK Mapping.

Regards,

Vaclav

I read the FK Mapping help before posting and it was not helpful.

Thanks bunches for the macro pointer. Hadn’t come across that yet.

Your recommendation to use an alternate key was a winner. Thanks!

You are welcome :slight_smile:

Vaclav