ADLINK-IST / opensplice

This is the Vortex OpenSplice Community Edition source repository. For our commercial offering see
https://www.adlinktech.com/en/vortex-opensplice-data-distribution-service
Apache License 2.0
259 stars 155 forks source link

One-to-many relationships can be captured using foreign keys? #134

Open ZTY-star opened 4 years ago

ZTY-star commented 4 years ago

How are foreign keys defined in IDL? What does it do?

vivekpandey02 commented 4 years ago

Hi ZTY-star, You can not define the foreign keys in IDL files. But you can use the foreign key concepts in your applications.

ZTY-star commented 4 years ago

Hi ZTY-star, You can not define the foreign keys in IDL files. But you can use the foreign key concepts in your applications.

Sorry, I do n’t understand. Can you give an example?

vivekpandey02 commented 4 years ago

To understand relationship in DDS you need to understand following concepts: Distributed Relational Information Modeling – Topic Keys can be used to identify instances as well as relationships – Relationships can be navigated by relying on a subset of SQL – One-to-many relationships can be captured using foreign keys – Many-to-many relationships need to be modeled using a topics – Keys can be represented by an arbitrary number of Topic fields

Suppose you have 3 topics named Floor,Room and TempSensor. Topics types are given below: Floor has a primary key fID. Room has a primary key rID and attribute fID is a foreign key. same in TempSensor, tID is a primary key and attribute rID acts as a foreign key.

struct Floor { short fID; short level; short open; };

pragma keylist Floor fID

struct Room { int rID; float width; float height; float length; short fId; // Foreign Key };

pragma keylist Room rID

struct TempSensor { short tID; float temp; float huminity; int rID; // Foreign Key
};

pragma keylist TempSensor tID

Now you need to maintain these relationship in your applications means you need to validate the received data as per the dependency and process accordingly.