Composite key

Hi

In the document servoytips.pdf from The Support Group I read the following about multiple keys:

…make sure that all of the columns that make up the key are marked as such in the Dataproviders dialog (sequence set to “db identity”). Once this is done, all of the normal databinding that happens by default will work (updates, searches, etc.). The catch comes if you plan to use controller.loadRecords() in your methods…

I don’t understand this chapter. Can anybody explain it to me? We often have composite keys. They are marked as pk in the database table. Should we mark the columns as DB Identity Sequence in Servoy? Do we miss performance or a feature if we don’t?

Thanks and regards

Birgit,

I think the it should say: marked as row_ident.

When the PK fields are defined as PKs in the table at sql level, Servoy will recognize that, otherwise you have to tell Servoy which columns to use as pk.
This is done by marking them as row_ident in the table editor.

Rob

Thank you, Rob, for explaining it. So, defining the pk in the datasbase is ok.

Best regards

I made some tests with row_ident and didn’t see any effect. I expected Servoy to deny entering twice the same value (same as ‘unique’ spoken in database wording). But nothing happened. Can you explain, what row_ident means and does?

Thanks and regards

Birgit,

It tells servoy to use the column as pk.
For example, if you have a pk column in the sql definition of the table (say col1) and you mark another column as row_ident (say col2), Servoy will treat the combination of these columns as the composite pk.
So updating a record will result in:
update tab set col3 = ? where col1 = ? and col2 = ?

If you enter the same value twice, Servoy will see those as the same record and may get confused, the combined column values must be unique together.
This only holds for the combination of the columns, each column value itself does not have to be unique.

Hope this makes it clear.

Rob

Hi Rob

Thank you for the answer. I tried defining a table in Servoy with columns id, name and firstname, id is the pk.

  1. I set name to row_ident. I created a form with two fields for name and firstname. I launched the form end entered data. I expected, that entering twice the same name would not be possible. But no restriction.

  2. I set name and firstname to row_ident. I opened the form and expected, that the values for name and firstname together must be unique. But no restriction. I could enter what ever I wanted.

  3. I removed the column id (pk). Still same behaviour.

What do I do wrong? How can I see the effect of row_ident?

Regards