Integrations (PTC products, 3rd party products and code) > Code integration (Ada, ARINC 653, C, C#, C++, IDL, Java, SQL and VB) > SQL code > Mapping information > Relationship mapping for SQL (SQL code)
  
Relationship mapping for SQL (SQL code)
For each Relationship:
In the creation file, ACS generates an alter table instruction that adds foreign keys to the table. Foreign keys are generated from the Foreign Columns that are created for Relationships in Modeler.
In the drop file, ACS generates an alter table instruction that removes the foreign keys from the table.
The One to One, Parent Optional and Cascade properties of the Relationship are ignored.
The name of the generated foreign key is the mangled name of the Modeler Foreign Column. For more information, see Setting up name conversions - optional (SQL code).
Example
Table1 and Table2 have a relationship through Relationship1. Because of Relationship1, Modeler creates the *Column1 foreign key in Table1 to reference the Table2 Column1 prime key.
If you generate Table1 using the SQL Server 2012 ACS Code Generator DLL, the creation file contains the following text.
ALTER TABLE Package1Table1
ADD CONSTRAINT Relationship1_Column1 FOREIGN KEY(Column1)
REFERENCES Package1Table2(Column1);
If you generate Table1 using the SQL Server 2012 ACS Code Generator DLL, the drop file includes the following text.
ALTER TABLE Package1 Table1 DROP CONSTRAINT Relationship1_Column1;