# Composite key

**URL:** <https://forum.servoy.com/t/composite-key/13173>\
**Category:** Classic Servoy\
**Created:** [November 11, 2010, 2:35pm UTC](https://forum.servoy.com/t/composite-key/13173 "2010-11-11T14:35:22Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![birgit](https://avatars.discourse-cdn.com/v4/letter/b/c5a1d2/32.png) [@birgit](https://forum.servoy.com/u/birgit)\
**Post date:** [November 11, 2010, 2:35pm UTC](https://forum.servoy.com/t/composite-key/13173/1 "2010-11-11T14:35:22Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![rgansevles](https://avatars.discourse-cdn.com/v4/letter/r/3d9bf3/32.png) [@rgansevles](https://forum.servoy.com/u/rgansevles)\
**Post date:** [November 17, 2010, 8:09am UTC](https://forum.servoy.com/t/composite-key/13173/2 "2010-11-17T08:09:04Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![birgit](https://avatars.discourse-cdn.com/v4/letter/b/c5a1d2/32.png) [@birgit](https://forum.servoy.com/u/birgit)\
**Post date:** [November 17, 2010, 1:09pm UTC](https://forum.servoy.com/t/composite-key/13173/3 "2010-11-17T13:09:04Z")

</div>

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

Best regards

---

<div class="post-metadata">

**Author:** ![birgit](https://avatars.discourse-cdn.com/v4/letter/b/c5a1d2/32.png) [@birgit](https://forum.servoy.com/u/birgit)\
**Post date:** [November 18, 2010, 10:58am UTC](https://forum.servoy.com/t/composite-key/13173/4 "2010-11-18T10:58:57Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![rgansevles](https://avatars.discourse-cdn.com/v4/letter/r/3d9bf3/32.png) [@rgansevles](https://forum.servoy.com/u/rgansevles)\
**Post date:** [November 18, 2010, 12:33pm UTC](https://forum.servoy.com/t/composite-key/13173/5 "2010-11-18T12:33:26Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![birgit](https://avatars.discourse-cdn.com/v4/letter/b/c5a1d2/32.png) [@birgit](https://forum.servoy.com/u/birgit)\
**Post date:** [November 19, 2010, 7:50am UTC](https://forum.servoy.com/t/composite-key/13173/6 "2010-11-19T07:50:16Z")

</div>

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
