Forums / General / Unique compound key for a class

"Please Note:
  • At the specific request of Ibexa we are changing this projects name to "Exponential" or "Exponential (CMS)" effective as of August, 11th 2025.
  • This project is not associated with the original eZ Publish software or its original developer, eZ Systems or Ibexa".

Unique compound key for a class

Author Message

Arlan Hair

Tuesday 22 November 2005 1:55:09 pm

What is the best way of creating a new class that requires a unique compound key.

Example
<b>Attribute</b>.......Key field
Project...........yes
Year..............yes
MoreInfo..........no

where there can only be one object that contains a given Project, Year.

Łukasz Serwatka

Wednesday 23 November 2005 11:40:50 pm

Hi Arlan,

You can us Identifier datatype as unique attribute, it will be unique around objects created from class which has this attribute.

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Arlan Hair

Monday 28 November 2005 7:34:49 am

Thanks Lukasz,
I need to clarify my request a little more. I am from the relational database era where you can specify a unique key over several fields (attributes) that will be entered by the user. In the example below I do not what to allow the user to add a second record with project=5100, Year=2005.
Existing objects
Project Year MoreInfo
5100 2003 los lorum...
5200 2003 qwert...
5100 2004 qwert...
5200 2004 qwert...
5100 2005 qwert...
My understanding of the Identifier datatype is an auto incremental number surrounded by hard coded text.