Page 1 of 1

Adding multiple pointer value to single row for one pointer column.

Posted: Wed Nov 06, 2013 4:16 pm
by Kartik A

I have two tables UserProfile and UserTransaction. In UserProfile table I have a column of type pointer to UserTransaction table. I could add a single value i.e UserTransaction _id to the UserProfile pointer column. How to add multiple UserTransation _id value to the pointer column of same UserProfile row.


Adding multiple pointer value to single row for one pointer column.

Posted: Wed Nov 06, 2013 4:51 pm
by Kartik A

Additional info - Is it possible to add array of pointers. How could I get for 1 UserProfile row related multiple objects from another table UserTransaction?

Thanks & Regards,
Kartik


Adding multiple pointer value to single row for one pointer column.

Posted: Wed Nov 06, 2013 11:59 pm
by Illya Stepanov

Hello Kartik,

Sorry for delay. Can you clarify - is your tables are on a different pages? And you want to transfer 'id' between this two pages?


Adding multiple pointer value to single row for one pointer column.

Posted: Thu Nov 07, 2013 6:58 pm
by Kartik A

Hi IIIya,

Its not on different pages. Nope I do not want to transfer id between two pages. What I am trying to do is - use pointer - As I mention previously I have two tables, UserProfile and UserTransaction. Each user could have multiple transactions. What I want to do is display UserProfile and all the transaction by that user on a single page. I can link 1 UserProfile with 1 UserTransaction row by adding pointer table to UserProfile table but that would retrieve only 1 UserTransaction row. If I want to retrieve multiple rows from UserTransaction table that belong to the 1 UserProfile row then how could I achieve it. Can I add multiple id's into a pointer column?

Below is the uploaded image that display what I am trying to achieve. if that cannot be done then what are the other options to achieve my requirement.

Image


Adding multiple pointer value to single row for one pointer column.

Posted: Thu Nov 07, 2013 10:15 pm
by Kateryna Grynko

Hi,

Sorry, still working on it. This will take some time. We'll update.


Adding multiple pointer value to single row for one pointer column.

Posted: Fri Nov 08, 2013 12:12 pm
by Oleg Danchenkov

No. You can't add multiple id's into a pointer column.
But you can save multiple id's into an Array column and retrieve data from UserTransaction collection with another REST service.


Adding multiple pointer value to single row for one pointer column.

Posted: Fri Nov 08, 2013 4:21 pm
by Kartik A

Thanks Oleg for your response. I have two followup question to your reply.

1) Do you mean pointer should be only used when we want to have 1 to 1 relationship. It cannot be used when I want to have 1 to many relationship. Like retrieving in single REST call master - detail rows.

2) What is the ideal/efficient way to implement one to many relationship so that it could be retrieved in single REST Call. Could you please explain briefly taking into consideration my above example of UserProfile and UserTransaction.

I went through documentation and couldn't find answers. Documentation has a brief explanation without example that make it difficult to get the clear understanding.

Please correct my limited understanding if I am wrong.

Thanks & Regards,
Kartik


Adding multiple pointer value to single row for one pointer column.

Posted: Fri Nov 08, 2013 6:03 pm
by Kateryna Grynko

Hi,

1) Yes.
2) In collection 'UserProfile' create a column 'UserTransactions' with data type = array. Save there all the values of UserTransaction id.


Adding multiple pointer value to single row for one pointer column.

Posted: Mon Nov 11, 2013 8:28 pm
by Ted6306214

So you can't have an object type with an array of pointers(w/includes)? You need to do another query to the detail table?


Adding multiple pointer value to single row for one pointer column.

Posted: Mon Nov 11, 2013 8:41 pm
by Kateryna Grynko

Hi Ted,

Yes.