cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Gelos
Super User
Super User

Powerapps

Hi, 

I have two cds table. How to assign one table column is primary key another table column is foreign key.

Please help me.

@Mike8 

@WarrenBelz 

@RandyHayes 

@Pstork1 

@v-xiaochen-msft 

@timl 

@BCLS776 

@Nogueira1306 

@v-bofeng-msft 

@gabibalaban 

4 REPLIES 4
dpoggemann
Super User
Super User

Hi @Gelos ,

 

If you have a 1:N relationship from table A to table B you can add a Lookup column to table B that will be to table A. This will create a the foreign key relationship between the two tables.  Setting up this relationship will allow you to add a sub-grid to Table A in the model forms to display table B records, you can see this in the "Related" tab as well in the Table A form to view all related records from Table B.  If you add the Lookup column for table A to the form for Table B it will allow you to click the link and navigate directly to Table A as well.  

 

Thanks,

 

Drew

Hope this helps. Please accept if answers your question or Like if helps in any way.
Thanks,
Drew

Thanks

What about 1:N and how to create primary key.

dpoggemann
Super User
Super User

Hi @Gelos ,

 

The primary key to the tables are the "Primary Name" field on the entity automatically.  When you create a table in Dataverse this field usually defaults to "Name" but you can change it.  It is a Text field that can be configured as AutoNumber as well but still a text field behind the scenes.  There is a GUID for each row as well but this is behind the scenes and not utilized in relationships with other tables...

 

If you add a new column in table B and select "Lookup" as the column type, it will give you the ability to select a table and you would select Table A here.  This will automatically create the 1:N relationship from Table A to Table B.  You can create other types of relationships as well like N:N but this would be done through a new Relationship from the table tabs and not what I am expecting you are trying to do here...

 

Thanks


Drew 

Hope this helps. Please accept if answers your question or Like if helps in any way.
Thanks,
Drew

Thank you

 

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Users online (6,116)