Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Data Model Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

How to define composite primary key in Silverstripe ORM/Dataobject


Go to End


2 Posts   1249 Views

Avatar
SSLearner

Community Member, 1 Post

20 May 2016 at 3:22am

How to define composite primary key in Silverstripe ORM/Dataobject

Silverstripes' ORM/Dataobject gives gives us to start with:

ID - primary key

But how you define composite key (primary key composed of 2 or more columns)? I've searched the documentation and it appears not mentioned anywhere.

Avatar
martimiz

Forum Moderator, 1391 Posts

9 June 2016 at 12:25am

I don't think you can. The entire SilverStripe CRM is based on each table having it's own unique ID that identifies the record ánd the relation between DataObjects, as well as (on a Database level) the relation between all tables that together form a DataObject. So I wouldn't want to mess with that...

What is the reason you would want to do this? Can it not be accomplished some other way?