Foreign key relationships for tables

Srikrishna Podduturi asked on June 10, 2019 07:18

Hi Team,

Could you please advise if we can add foreign key relationships between two tables created using page types. I want to get data from multiple tables which are related to each other and i want to get this data at once using relationships as we do in Entity Framework.

Thanks, Krishna.

Recent Answers


Juraj Ondrus answered on June 10, 2019 08:05

You can do so but it is not recommended - it can cause issues when working with the Kentico API or with the pages and page types in Admin UI - Kentico does not expect FK to be there, so e.g. deleting records could cause issues. What exactly you want to achieve? Maybe there is some other way around.

0 votesVote for this answer Mark as a Correct answer

Srikrishna Podduturi answered on June 10, 2019 16:36

Thanks for your answer.

I have to get all products and related items list and display in a web page. I have product related items in 2 other tables which i have created using page type. So instead of getting these with 3 database hits, I want to get the product and related items in a single database hit. Is it possible using Kentico?

Thanks, Krishna.

0 votesVote for this answer Mark as a Correct answer

Juraj Ondrus answered on June 11, 2019 06:59

Have you considered using page relationships? This way you can add a new field to your page type and in this filed you will be selecting the related page items and then, you can display them on the page too.

0 votesVote for this answer Mark as a Correct answer

Srikrishna Podduturi answered on June 11, 2019 07:53

Thanks Juraj Ondrus. I will give it a try.

0 votesVote for this answer Mark as a Correct answer

Srikrishna Podduturi answered on June 11, 2019 11:09 (last edited on June 11, 2019 11:10)

Hi Juraj Ondrus,

One more question. I have added an extra column in Media libraries using Modules section. The column has appeared in the Media_File table.

I am inserting records into media libraries using API i.e. MediaFileInfoProvider.SetMediaFileInfo(mediaFile)

Could you please advise how can i add a value to the newly added column using the above API method?

Thanks.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.