Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Primary Foreign relation in ACM

Avatar

Avatar
Boost 1
Level 1
abhiseks1679239
Level 1

Likes

2 likes

Total Posts

6 posts

Correct Reply

0 solutions
Top badges earned
Boost 1
View profile

Avatar
Boost 1
Level 1
abhiseks1679239
Level 1

Likes

2 likes

Total Posts

6 posts

Correct Reply

0 solutions
Top badges earned
Boost 1
View profile
abhiseks1679239
Level 1

10-08-2020

Hi Experts,

 

If I understand correctly, if we declare a key in adobe data schema, it creates an unique index with not null constraint enforced in the backend table (not exactly an Oracle primary key).

I'm trying to implement Primary-Foreign key relation in ACM. I've declared a link between the tables (code below).
However, it doesn't enforce this in backend database (parent-child validations don't take place).
Sample code below:

Scenario: Parent table (test1) & child table (test2). Sample below:

test1:

<element label="test1" name="test1">

   <key internal="true" name="PKEY_t1">
     <keyfield xpath="@col1"/>
   </key>

   <attribute label="col1" name="col1" type="long"/>
   <attribute label="col2" name="col2" type="string"/>
   <attribute label="col3" name="col3" type="string"/>
</element>

test_1.JPG

 

 

test2:

<element label="test2" name="test2">

   <key internal="true" name="PKEY_t2">
     <keyfield xpath="@col1"/>
   </key>

   <attribute label="col1" name="col1" type="long"/>
   <attribute label="col2" name="col2" type="long"/>
   <attribute label="col3" name="col3" type="string"/>

   <element label="test_link" name="test_link" target="pl_:test1" type="link">
   <join xpath-dst="@col1" xpath-src="@col2"/>
   </element>

</element>

test_2.JPG

 

Please suggest.

Foreign key Primary key Relationships

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Contributor
MVP
Milan_Vucetic
MVP

Likes

166 likes

Total Posts

384 posts

Correct Reply

135 solutions
Top badges earned
Contributor
Springboard
Shape 1
Validate 25
Validate 10
View profile

Avatar
Contributor
MVP
Milan_Vucetic
MVP

Likes

166 likes

Total Posts

384 posts

Correct Reply

135 solutions
Top badges earned
Contributor
Springboard
Shape 1
Validate 25
Validate 10
View profile
Milan_Vucetic
MVP

11-08-2020

Hi @abhiseks1679239

define cardinality in the link according to your use case. 

Find the Links: relation between tables section here: link

Regards,

Milan

 

abhiseks1679239

@Milan_VuceticHi, after i created the tables...below was what got created:

Parent - pl_:test1

<element label="test2" name="test2-test_link" revLink="test_link" target="pl_:test2"
             type="link" unbound="true">
      <join xpath-dst="@col2" xpath-src="@col1"/>
</element>

 

Child - pl_:test2

<element label="test_link" name="test_link" revLink="test2-test_link"
     target="pl_:test1" type="link">
    <join xpath-dst="@col1" xpath-src="@col2"/>
</element>

 

I believe this was 1-1 cardinality which is created by default? Even so, i was able to insert a record in child table (test2), which didn't exist in parent table(test1). hence, my doubts.

 

If it's possible, can you give me an example of how you'd define a link of cardinality 1-N.

Thank you

Sukrity_Wadhwa
Hi @ Milan_Vucetic, Would you be able to help @abhiseks1679239 with an example? Thanks!
Milan_Vucetic

Hi @abhiseks1679239,
cardinality 1-N is created by default always. In order to create 1-1 relation add the following: revCardinality="single"

If you want to create ref. integrity consider this:

 

integrity (optional): referential integrity of the occurrence of the source table to the occurrence of the target table. Possible values are as follows:
  • define : it is possible to delete the source occurrence if it is no longer referenced by a target occurrence,
  • normal : deleting the source occurrence initializes the keys of the link to the target occurrence (default mode), this type of integrity initializes all foreign keys,
  • own : deleting the source occurrence leads to the deletion of the target occurrence,
  • owncopy : the same as own (in case of deletion) or duplicates the occurrences (in case of duplication),
  • neutral : does nothing.

Regards,

Milan

 

Answers (1)

Answers (1)

Avatar

Avatar
Establish
MVP
wodnicki
MVP

Likes

976 likes

Total Posts

1,096 posts

Correct Reply

514 solutions
Top badges earned
Establish
Affirm 500
Contributor
Shape 1
Give Back 100
View profile

Avatar
Establish
MVP
wodnicki
MVP

Likes

976 likes

Total Posts

1,096 posts

Correct Reply

514 solutions
Top badges earned
Establish
Affirm 500
Contributor
Shape 1
Give Back 100
View profile
wodnicki
MVP

11-08-2020

Hi,

 

Relationships defined in ACC are used only by ACC software, not the RDBMS software.

 

Thanks,

-Jon