Monday, 3 June 2019

Maintaining the One-to-Many (m = CN) cardinality between the Check table & Foreign Key table and using the combined key

Introduction: In this article we are going to learn how to provide the one to many ( m = CN ) cardinality between the check table and foreign key tables. one to many carnality can be selected upon our requirement while providing the foreign key relationship from key fields of foreign key table to check table key fields . One to many ( m = CN) cardinality refers there many be many matching records in the foreign key table for each record of the check table.

Below are the steps to maintain the one to many ( m = CN ) cardinality between the check table and foreign key table.

Check table is the master data table with unique key field value records.

Foreign key table is the dependent table where each record is checked against the check table key fields with which foreign key relationship has been maintained with appropriate cardinality.

Step 1. Create a database table ZTAB1 using tcode SE11 with the below fields NUM, NAME fields and maintain the NUM as the keyfield.


Step 2. Select the Data Browser/Table View Maint. value as Display/Maintenance Allowed under Delivery and Maintenance tab.


Step 3. Maintain the proper values under the Technical Settings.


Step 4. Create the entries by going through the Utilities ->Table Contents -> Create Entries


Step 5. Enter the record and click on Save button.


Step 6. Now the ZTAB1 table having only one record as shown below.


Step 7. Now create another table ZTAB2 using tcode SE11 with the following fields

NUM, VILLAGE and maintain the NUM field as the key field as shown below.




Step 8. Now maintain the foreign key relationship with table ZTAB2 by giving the check table as ZTAB1 and click on Generate Proposal button , Foreign key field type as Key fields/Candidates and cardinality as 1 : CN then click on Copy button.


Step 9. Now make the Village field also as key field and activate the table. so that here the NUM and VILLAGE is combined key for table ZTAB2.


Step 10. Now create the entry in ZTAB2 table by going through Utilities ->Table Contents ->Create Entries.


Step 11. Now create the entries with combined key NUM and VILLAGE as shown below.



Step 12. The records in the ZTAB2 as shown below.

No comments:

Post a Comment