Discussion:
Is (RecId, TableId) always unique?
(too old to reply)
Adam
2007-09-19 20:06:01 UTC
Permalink
Hello,

Is the recId unique for all records within a table?

I want to link some data to sales lines and the same data to miscellaneous
charges. If I link the data using the primary keys, I'd need two different
tables since they have different primary keys. But if the recId is always
unique for all records in each table, then I can just use one table and
(recId, tableId) for my foreign key. Any suggestions?

Thanks,
Adam
chris (toronto)
2007-09-19 21:58:03 UTC
Permalink
Hey Adam,

Yes... recId should be always unique within tables unless you have some
major problems.

Some AX tables use this method to lookup/find records when there are
multiple tables involved.

I think the "standard" is to create 2 fields in your table... refTableId &
refRecId

Store the tableId & the recid there and your good... You can then build a
findref function that accepts the tableId & recid to return your unique
record.

Look at the table custTransOpen, it uses this idea.

Chris
Post by Adam
Hello,
Is the recId unique for all records within a table?
I want to link some data to sales lines and the same data to miscellaneous
charges. If I link the data using the primary keys, I'd need two different
tables since they have different primary keys. But if the recId is always
unique for all records in each table, then I can just use one table and
(recId, tableId) for my foreign key. Any suggestions?
Thanks,
Adam
Adam
2007-09-20 13:38:04 UTC
Permalink
Hi Chris,

That's great news! Thanks for confirming this for me. This will make my
implementation much cleaner.

Thanks again,
Adam
Post by chris (toronto)
Hey Adam,
Yes... recId should be always unique within tables unless you have some
major problems.
Some AX tables use this method to lookup/find records when there are
multiple tables involved.
I think the "standard" is to create 2 fields in your table... refTableId &
refRecId
Store the tableId & the recid there and your good... You can then build a
findref function that accepts the tableId & recid to return your unique
record.
Look at the table custTransOpen, it uses this idea.
Chris
Post by Adam
Hello,
Is the recId unique for all records within a table?
I want to link some data to sales lines and the same data to miscellaneous
charges. If I link the data using the primary keys, I'd need two different
tables since they have different primary keys. But if the recId is always
unique for all records in each table, then I can just use one table and
(recId, tableId) for my foreign key. Any suggestions?
Thanks,
Adam
Loading...