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.

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 21:03:39
Script start
Timing: Jan 18 2025 21:03:39
Module start 'layout'
Timing: Jan 18 2025 21:03:39
Module start 'content'
Timing: Jan 18 2025 21:03:39
Module end 'content'
Timing: Jan 18 2025 21:03:39
Script end

Main resources:

Total runtime0.6088 sec
Peak memory usage4,096.0000 KB
Database Queries57

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0067 587.9063152.6250
Module start 'layout' 0.00670.0043 740.531339.4453
Module start 'content' 0.01100.5966 779.9766535.9688
Module end 'content' 0.60760.0012 1,315.94538.1641
Script end 0.6088  1,324.1094 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00340.5564160.0002
Check MTime0.00130.2189160.0001
Mysql Total
Database connection0.00090.149310.0009
Mysqli_queries0.561492.2146570.0098
Looping result0.00070.1160550.0000
Template Total0.574594.420.2873
Template load0.00220.365320.0011
Template processing0.572394.005420.2862
Template load and register function0.00020.035810.0002
states
state_id_array0.00240.389810.0024
state_identifier_array0.00100.165220.0005
Override
Cache load0.00180.2961250.0001
Sytem overhead
Fetch class attribute can translate value0.00050.084620.0003
Fetch class attribute name0.00130.217340.0003
XML
Image XML parsing0.00060.102520.0003
class_abstraction
Instantiating content class attribute0.00000.001640.0000
General
dbfile0.00070.1176180.0000
String conversion0.00000.001840.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
3content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
4content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
2content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 12
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs