Create relationships specifying existing foreign keys
Question
Application Type
Reactive
Service Studio Version
11.53.8 (Build 60995)

In the tutorials, when we create relationships, the systems creates foreign keys even when a foreign key already exists in the underlying data model. Is there any way to bypass this and specify the foreign key? 

mvp_badge
MVP
Solution

Hi Bilal,

I'm not sure I understand what you mean. You do not "create a relationship" between entities explicitly, you create them implicitly by adding an attribute that's an identifier of another entity (i.e., you create a foreign key). The system therefore does not "create a foreign key when we create relationships" - it's the other way around.

In the tutorials we are walked through dragging the entities to the entity relationship model and then creating relationships between any two entities, and when we do that, the system creates foreign keys automatically without checking if the entity already has a foreign key.

Hi Bilal,

1. If you have a physical database where a table has FK to other table, then it is good to be reflected in the Outsystems  data abstraction layer / entity.

2. If the physical table do not have a FK to other table, like my case when using external data Single Store, u still can assign a column with type of identifier to other entity - it is not FK physically, but it can inform Outsystems to create automatically, say screen with dropdown to the referenced entity

regards

Is there a way that the system automatically creates the relationships between entities as they are defined in the underlying database without me going through the Entity Relationship Model?

First, there is two types of database:

1. Internal Database/ System Interface

2. External Database 

When u mean the first one, the FK is defined when u give a column with data type "Identifier" to other entity. So, u do not need to go  to Entity Diagrams to make a relationship. The underlying database has inferred the FK from the data types.

For the second case as the database is external, the FK is already defined by ourselves in the DBMS, not by Outsystems. However, we can still make developer's life easier, by setting the data type, say in the database is long integer, to be a type of an identifier. This information will be useful when OS generates/scaffolding a screen, to say a few.

Thanks



First, there is two types of database:

1. Internal Database/ System Interface

2. External Database 

When u mean the first one, the FK is defined when u give a column with data type "Identifier" to other entity. So, u do not need to go  to Entity Diagrams to make a relationship. The underlying database has inferred the FK from the data types.

For the second case as the database is external, the FK is already defined by ourselves in the DBMS, not by Outsystems. However, we can still make developer's life easier, by setting the data type, say in the database is long integer, to be a type of an identifier. This information will be useful when OS generates/scaffolding a screen, to say a few.

Thanks



mvp_badge
MVP
Solution

Hi Bilal,

I'm not sure I understand what you mean. You do not "create a relationship" between entities explicitly, you create them implicitly by adding an attribute that's an identifier of another entity (i.e., you create a foreign key). The system therefore does not "create a foreign key when we create relationships" - it's the other way around.

In the tutorials we are walked through dragging the entities to the entity relationship model and then creating relationships between any two entities, and when we do that, the system creates foreign keys automatically without checking if the entity already has a foreign key.

Hi Bilal,

1. If you have a physical database where a table has FK to other table, then it is good to be reflected in the Outsystems  data abstraction layer / entity.

2. If the physical table do not have a FK to other table, like my case when using external data Single Store, u still can assign a column with type of identifier to other entity - it is not FK physically, but it can inform Outsystems to create automatically, say screen with dropdown to the referenced entity

regards

Is there a way that the system automatically creates the relationships between entities as they are defined in the underlying database without me going through the Entity Relationship Model?

First, there is two types of database:

1. Internal Database/ System Interface

2. External Database 

When u mean the first one, the FK is defined when u give a column with data type "Identifier" to other entity. So, u do not need to go  to Entity Diagrams to make a relationship. The underlying database has inferred the FK from the data types.

For the second case as the database is external, the FK is already defined by ourselves in the DBMS, not by Outsystems. However, we can still make developer's life easier, by setting the data type, say in the database is long integer, to be a type of an identifier. This information will be useful when OS generates/scaffolding a screen, to say a few.

Thanks



Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.