ERPClimb logoERPClimb
Type system and data models
SAP Commerce Cloudbeginner 6 min read

Type system and data models — SAP Guided Tutorial

Free sample lesson · open to everyone

Key takeaway

Defining the SAP Commerce data model in items. xml: item types, attributes, relations and enumerations, deployment tables, generated models, and how to evolve the model without performance or upgrade problems.

In this lessonShow sections

Visual overview

Type system and data models — learning sheetFlow: items.xml → Build: generated models → System update → Use via ModelService. Key ideas: DEFINING TYPES; DEPLOYMENT AND PERFORMANCE; RELATIONS; EVOLVING THE MODEL. Watch out: Types without their own deployment and huge many-to-many relations are classic causes of slow queries.ERPClimb.com / COMMERCE / LESSON 2/12 / LEARNING SHEETType system and data models1 · HOW IT FLOWS1items.xml2Buildgenerated models3System update4Use viaModelService2 · KEY IDEAS EXPLAINEDDefining Typesitemtype code, extends,jaloclass/autocreate/generate settings as perproject standards.Attributes with type, persistence and modifiers(read, write, optional, unique).Deployment And Performance<deployment table="..."typecode="..."/> gives a type its owntable; typecodes must be unique in the project…Index frequently searched attributes.RelationsOne-to-many and many-to-many relations defined initems.xml.Many-to-many creates a link table; consider volumeand ordering needs.Evolving The ModelAdding attributes: build + system update (with'update running system').Renaming/removing: plan migration; old columns mayremain.3 · REMEMBER · WATCH OUTRememberTypes are defined in an extension's items.xml: itemtype, attributes,relations, enumtype, collectiontype.A build generates Java model classes; a system update creates oralters database columns.New item types should declare their own deployment (table) to avoidlanding in the generic items table.!Watch outTypes without their own deploymentand huge many-to-many relations areclassic causes of slow queries.4 · IN A REAL PROJECTA custom 'StoreReview' type was created without a deployment table. After a year, millions of reviews sat inthe generic items table and every query on generic items slowed down. Migrating reviews to a dedicated tablerestored performance.Original ERPClimb learning sheet • Verify against your SAP release and edition

The situation: a real project scenario

A custom 'StoreReview' type was created without a deployment table. After a year, millions of reviews sat in the generic items table and every query on generic items slowed down. Migrating reviews to a dedicated table restored performance.

Explanation

The data model is the foundation everything else in SAP Commerce builds on, and it's defined declaratively in an extension's items.xml rather than through code-first ORM annotations.

An itemtype entry declares a new type (code, what it extends, and settings like autocreate/generate that control whether a Java model class is produced), its attributes (with a Java type, a persistence setting, and modifiers like optional, unique, read/write), plus any enumtypes (for fixed value lists) or relations needed between types. Every build regenerates the Java model classes from these definitions, and a system update applies the corresponding changes to the database schema — creating or altering columns to match.

The single most consequential decision when defining a new type is whether it gets its own deployment table.

A deployment table/typecode entry gives the type a dedicated table with its own typecode (which must be unique within the project's assigned range); without it, instances of that type fall into the generic, shared items table that every undeployed type uses — which works fine at small volumes but becomes a serious performance problem once that type accumulates real volume, because every query against the generic table now has to filter through everyone else's undeployed data too.

Relations model one-to-many and many-to-many associations between types; many-to-many relations create a link table under the hood, and large ones need the same volume-awareness as any other high-cardinality relationship — they shouldn't be treated as free just because they're declared in a few lines of XML.

Evolving the model over time has different levels of risk: adding a new attribute is routine (build plus a system update, 'update running system'), but renaming or removing an attribute needs an actual migration plan, since old columns can linger and old code or data can still reference the previous shape. Because items.xml changes affect every single environment that runs that extension, they deserve the same review rigor as any other change that touches the database schema in a shared system.

Code example

ABAP Code
<itemtype code="StoreReview" autocreate="true" generate="true">  <deployment table="StoreReviews" typecode="25010"/>  <attributes>    <attribute qualifier="rating" type="java.lang.Integer">      <persistence type="property"/>      <modifiers optional="false"/>    </attribute>    <attribute qualifier="comment" type="java.lang.String">      <persistence type="property"><columntype><value>HYBRIS.LONG_STRING</value></columntype></persistence>    </attribute>  </attributes></itemtype>

Watch out

Common mistakes

Creating a new item type without its own deployment table: it looks fine during development with a handful of test rows, and only becomes a visible problem much later once the type has accumulated real volume and every query against the shared generic items table slows down because of it.

Using collection-type attributes for what is really a large, growing list of related items, instead of modeling it as a proper relation — collection attributes don't scale the way a dedicated relation table does. Typecode collisions with SAP's own extensions or other custom extensions, usually from not checking the project's assigned typecode range before picking a number.

Changing types directly in a production environment without planning the schema migration first — even an apparently simple attribute rename can leave old columns, orphaned data, or code that still expects the old shape.

Do this

Best practices

Always define an explicit deployment table for any new item type expected to hold real business data, rather than letting it default into the shared generic items table — the cost of doing this upfront is trivial compared to migrating a type out of the generic table after it's grown large.

Review every items.xml change for its performance and migration impact before merging, the same way you'd review a raw schema migration in any other system, because that's effectively what it is. Use proper relations, not collection attributes, for one-to-many or many-to-many associations with real volume or that need independent querying.

In the interview

Interview angle

A common items.xml interview question is 'You're adding a new custom type that will hold millions of rows eventually — what do you need to get right from day one?' A weak answer just describes the itemtype/attribute syntax.

A strong answer leads with the deployment table: give the type its own table and typecode from the start, because recovering from a type that's been living in the generic items table for a year, once it's grown large enough to slow down every other undeployed type's queries, means migrating real production data under pressure instead of making a one-line XML decision upfront.

Mentioning typecode range discipline and the difference in migration risk between adding an attribute versus renaming one rounds out a strong answer.

Practice this lesson

Original educational case studies for SAP consultants, not official SAP certification exam questions. Verify product edition and implementation details against the current SAP documentation.

Quick check

0 of 4 questions attempted

Question 1 of 4

Where are SAP Commerce item types defined?

Practise this in an interview

Answer in your own words and get instant feedback, the way an interviewer would judge it.

1How do you design a new data entity in SAP Commerce?

2What problems can a poor type system design cause?

Was this lesson helpful?

Keep exploring

Check before use: lesson examples are educational, not a guarantee of correctness for your SAP edition or release. Sample code has not been executed on your SAP system. Confirm API availability, syntax, authorizations and business impact in an approved development or test environment.