Suppose I have 4 tables like

1. Product (ID,Name) - master table
2. Client (ID, Name, City) - master table

3. Order (ID, Date, ClientID, Detail)

4. OrderProduct (ID, OrderID, ProductID, Quantity)


the first 2 tables are very simple and have master entries and I have mentioned in 2 sheets in excel file.

but the rest 2 have foreign key relationship keys including in it. so can I mentioned these columns in excel file with dump data and import it ?
Is it possible or how come it possible? 


Hi Manish,

The only way it is possible is for you to configure your first two entities' Id attributes to not be Auto-Number (which in itself is generally seen as a bad idea). That would mean that the ID specified in the Excel file would be the one used, and as such, the data in the following two entities would be correct.

Typically you don't want to store IDs in Excel files... if possible, use other attributes that are also unique (like a product's UPC for instance), and modify the bootstrap logic of the last two entities to fetch the right record (based on the unique attribute - instead of a ProductID the Excel would have the UPC that could then be searched during bootstrap to find the correct Product's Id)

Hope this helps

Hi Manish,

Yes it is possible.

The easiest way is if you have the data all denormalized available in a spreadsheet, meaning that one row in the spreadsheet contains the data for product, client, order and orderproduct. This would allow you to easily upsert client and products based on their name.

Alternatively if your spreadsheet already contain the IDs you could consider to, deviate away from OutSystems default behaviour to automatically assign ID's and set the Autonumber property of the entities to false. Important in this scenario that you have import the entities in the correct order: product, client, order, orderproduct.

Regards,

Daniel


Hello Manish

It is very much possible to import/ bootstrap entities with Foreign Keys. 

In addition to what has already been stated by Daniel and Jorge. 

I had uploaded a component on forge NorthWind DB, in which you can refer to the bootstrapping of entities with Foreign keys.  

The Northwind DB has entities like Products, Orders, OrderDetails, Customers etc. 

This should give you good guidance on how to go about with your requirement. 


Hope this helps !!!