Pk and fk relationship

Hi Team,

I have two excels,products and customers for 1 to many relationship,customers will have multiple instances of products.product names I want to make as pk?will this be possible.

I want to import excel with data,do I need to set product name as unique and how to set fk in customer table,and in product table do I need to set Id only as pk?,if the data is already present in excel.

Please provide an example how to import this data with constraints mentioned,

Hi Ujwwala,

Please find the below link to get more idea about entity relationship.

Entity Relationship

Dileep

mvp_badge
MVP

Hi Ujwwala,

When you create a new Entity in OutSystems, by default it will have a primary key called Id, which is an auto number Long Integer. Almost never you will need to change this. A foreign key is an Entity Attribute that references the primary key of another Entity. You create it by adding an Attribute to an Entity and setting it's type to XXX Identifier, where XXX is the name of the other Entity.

You say that customers and products have a 1:n relationship, but I think in fact that's a n:n relationship, as though one customer can have multiple products, a single product can be bought by multiple customers. Typically, you would use an associative entity that contains both a Customer Id and a Product Id, or - in case a customer can purchase multiple times - you'd have an "Order" Entity that contains a Customer Id as foreign key, and an associative entity containing the Order Id and a Product Id.

As for importing via Excels, there's no out-of-the-box solution for that. You should first import the products and customers, then bootstrap the associative entity based on the data in the Excel file.

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