Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Oracle eCommerce (ATG) Database Best Practices

1,458 views

Published on

Oracle eCommerce (ATG) Database Best Practices for ATG Developers and ATG Database admins

Published in: Software

Oracle eCommerce (ATG) Database Best Practices

  1. 1. ATG DB BEST PRACTICES BY KATE SEMIZHON
  2. 2. 2
  3. 3. ATGOOTBDB SCHEMAS 3
  4. 4. TABLE TYPES • ATG OOTB • New item-descriptors Primary • Extending OOTB tables Auxiliary • One-to-many • Many-to-many Multi
  5. 5. AUXILIARY TABLES 1. In ATG, VARCHAR2 is almost always used as a data type for primary key column. Auxiliary tables should use the same data type length for referencing primary table. 2. Auxiliary table MUST reference PRIMARY table but not any other auxiliary table.
  6. 6. AUXILIARY TABLES CREATE TABLE PRIMARY ( ID VARCHAR2 (40) NOT NULL, NAME VARCHAR2 (40) NOT NULL, CONSTRAINT PRIMARY_PK PRIMARY KEY (ID) ); CREATE TABLE AUX1( ID VARCHAR2 (40) NOT NULL, SOME_PROP VARCHAR2 (400), CONSTRAINT AUX1_PK PRIMARY KEY (ID), CONSTRAINT AUX1_FK FOREIGN KEY (ID) REFERENCES PRIMARY (ID) ); CREATE TABLE AUX2 ( ID VARCHAR2 (40) NOT NULL, SOME_PROP VARCHAR2 (40), CONSTRAINT AUX2_PK PRIMARY KEY (ID), CONSTRAINT AUX2_FK FOREIGN KEY (ID) REFERENCES PRIMARY(ID) -- THIS IS CORRECT! );
  7. 7. MULTI TABLES
  8. 8. Confidential 8 Primary table Primary table multi Primary key
  9. 9. Confidential 9 Primary table Primary table multi Primary key
  10. 10. Confidential 10 Primary table Primary table multi Primary key
  11. 11. one-to-many from both sides CREATE TABLE CONTENT( CONTENT_ID VARCHAR2 (40) NOT NULL, DESCRIPTION VARCHAR2 (254) NULL , CONSTRAINT CONTENT_IMAGES_PK PRIMARY KEY (CONTENT_ID) ); CREATE TABLE IMAGES ( IMAGE_ID VARCHAR2 (40) NOT NULL, URL VARCHAR2 (254) NULL , CONSTRAINT CONTENT_IMAGES_PK PRIMARY KEY (IMAGE_ID) ); CREATE TABLE CONTENT_IMAGES ( CONTENT_ID VARCHAR2 (40) NOT NULL REFERENCES CONTENT(CONTENT_ID), IMAGE_ID VARCHAR2 (254) NOT NULL REFERENCES IMAGES(IMAGE_ID) , CONSTRAINT CONTENT_IMAGES_PK PRIMARY KEY (CONTENT_ID , IMAGE_ID) ); MANY-TO-MANY RELATIONSHIPS 11
  12. 12. VERSIONED SCHEMA
  13. 13. PRIMARY TABLES 1) The following columns should be added to every table that represents a primary table for an item descriptor: Confidential 13 asset_version INTEGER NOT NULL workspace_id varchar2(254) NULL branch_id varchar2(254) NULL is_head number(1) NULL version_deleted varchar2(254) NULL version_editable varchar2(254) NULL pred_version INT NULL checkin_date DATE NULL
  14. 14. PRIMARY TABLES 2) Primary key Original Primary Key + ASSET_VERSION 3) Remove from all tables: • All foreign key references. • All unique constraints on columns. • All unique indexes on columns.
  15. 15. PRIMARY TABLES 4) Indexes all primary tables in the versioned schema have indexes on workspace_id and checkin_date create index type_x_workspace_id on type_x (workspace_id); create index type_x_checkin_date_id on type_x (checkin_date);
  16. 16. PRIMARY TABLES. EXAMPLE create table type_x ( type_x_id VARCHAR2(16) NOT NULL, asset_version INT NOT NULL, branch_id VARCHAR2(40) NULL, is_head NUMERIC(1) NULL, version_deleted NUMERIC(1) NULL, version_editable NUMERIC(1) NULL, workspace_id VARCHAR(40) NULL, pred_version INT NULL, checkin_date TIMESTAMP NULL, name VARCHAR2(128) NULL, type_y_ref_id VARCHAR2(16) NULL, PRIMARY KEY (type_x_id, asset_version) ); create index type_x_workspace_id on type_x (workspace_id); create index type_x_checkin_date_id on type_x (checkin_date);
  17. 17. AUXILIARY TABLES 1) The following column should be added to every table that represents an auxiliary or multi table in an item descriptor: asset_version INT NOT NULL 2) Primary key Original Primary Key + ASSET_VERSION
  18. 18. AUXILIARY TABLES 3) Remove from all tables: • All foreign key references. • All unique constraints on columns. • All unique indexes on columns
  19. 19. AUXILIARY TABLES. EXAMPLE Original DDL: CREATE TABLE dcs_cat_media ( category_id varchar2(254) NOT NULL REFERENCES dcs_category(category_id), template_id varchar2(254) NULL REFERENCES dcs_media(media_id), PRIMARY KEY(category_id) ); Versioned Schema DDL: CREATE TABLE dcs_cat_media ( category_id varchar2(254) NOT NULL, asset_version INTEGER NOT NULL, template_id varchar2(254) NULL, PRIMARY KEY(category_id, asset_version) );
  20. 20. MULTI TABLES 1) The following column should be added to every table that represents an auxiliary or multi table in an item descriptor: asset_version INT NOT NULL sec_asset_version INT NOT NULL 2) Primary key Original Primary Key + asset_version + sec_asset_version
  21. 21. MULTI TABLES 3) Remove from all tables: • All foreign key references. • All unique constraints on columns. • All unique indexes on columns
  22. 22. ONE-TO-MANY. EXAMPLE Original DDL CREATE TABLE dcs_cat_chldprd ( category_id varchar2(254) NOT NULL REFERENCES dcs_category(category_id), sequence_num INTEGER NOT NULL, child_prd_id varchar2(254) NULL REFERENCES dcs_product(product_id), PRIMARY KEY(category_id, sequence_num) ); Versioned DDL CREATE TABLE dcs_cat_chldprd ( category_id varchar2(254) NOT NULL, asset_version INTEGER NOT NULL, sequence_num INTEGER NOT NULL, child_prd_id varchar2(254) NULL, sec_asset_version INTEGER NOT NULL, PRIMARY KEY(category_id, sequence_num, asset_version, sec_asset_version) );
  23. 23. MANY-TO-MANY. EXAMPLE Original DDL CREATE TABLE dcs_catfol_chld ( catalog_id varchar2(254) NOT NULL REFERENCES dcs_catalog(catalog_id), catfol_id varchar2(254) NOT NULL REFERENCES dcs_gen_fol_cat(folder_id), sequence_num INTEGER NOT NULL, PRIMARY KEY(catalog_id, catfol_id, sequence_num) ); Versioned DDL CREATE TABLE dcs_catfol_chld ( catalog_id varchar2(254) NOT NULL, sec_asset_version INTEGER NOT NULL, catfol_id varchar2(254) NOT NULL, sequence_num INTEGER NOT NULL, asset_version INTEGER NOT NULL, PRIMARY KEY(catalog_id, catfol_id, sequence_num, asset_version, sec_asset_version) );
  24. 24. THANK YOU! QUESTIONS?
  25. 25. RESOURCES ATG documentation: http://docs.oracle.com/cd/E26180_01/Platfor m.94/ATGCAProgGuide/ATGCAProgGuide.pdf

×