Backendless Support
 
Answered

Is Join Possible

Asslam-o-Alikum

I have two table

1)"User" contains(email, pass,Location)

2)"Group" contains(memberEmail(that is user Email) ,groupname)

i want to retrieve locations from "User" table of all those user which have same groupname in "Group" table.

how can i do that

Leave a Comment

Comments (15)

photo
1

Hi Sufi,

SQL joins, as well as any other SQL-specific functionalities, are by design not available in Backendless data storage. Instead, we implement more of an object-oriented storage where you have objects and relations between them. You may think of it as a reflection of the classes structure in your code, where the class maps directly to the table: i.e. class has fields, which may be references to other classes, and table has columns, which also may be references to other tables (relations in terms of Backendless).

Using the object-oriented approach you can implement your use case much more easier than with joins. You can set up a relation from Users table to Group table named group and then you'll be able to retrieve users for a group with a simple query on the Users table:

  1. group.name = 'your_group_name'

This will return all users belonging to the specified group. From these users you'll be able to retrieve the Location property.

I highly recommend you to read our Data Service documentation to get acquainted with the model we implement and how to use it. It contains lots of examples and describes many features you may be happy to find available out-of-the-box.

photo
1

Waslam Sergey

Can u please give some example....or specific topic to search... i have no idea about object oriented storage.

photo
photo
1

I m working on Android application. On Java coding.custom classes give example accodring to that

photo
1

Sure, here is the Android/Java specific documentation section about Data Service: http://backendless.com/docs/android/doc.html#dynanchor3

It contains examples for each method in SDK.

photo
photo
1

Yeah i checked.. but did not find ....can you send any code accoding to my question...

photo
1

After you add a column of type DATA OBJECT RELATIONSHIP named group to your Users table and set up proper related objects (in other words, connect users with their group), you can run the following query with a where clause against the Users table:

  1. DataQueryBuilder query = DataQueryBuilder.create().setWhereClause( "group.name = 'My Group'" );
  2. List<BackendlessUser> groupUsers = Backendless.Data.of( BackendlessUser.class ).find( query );

photo
1

Thanks Sergey for detail answer

Just Last Thing how can i add a column of type DATA OBJECT RELATIONSHIP named group to your Users table???.... code or Screen short please

photo
1

a user may b member of multiple groups

photo
1

Here's a doc describing how to add relation columns in developer's console, with screenshots: http://backendless.com/docs/android/doc.html#data_relations

If a user may be a member of multiple groups, then the relation cardinality should be One to Many, so that a single user object may have many related group objects.

photo
1

Thank Sergey

3fb0a59d74b9b8199c2e6af1cac2d2bd

please explane how where clause work..to get Location from User table where group name in Family circle is "AnyGroup"

photo
1

just write the code of get user Location from User Table where Group name is "My group" in Group Table...thankx

photo
1

Sorry, we do not write code for our users due to our support policy.

I've already given you a few examples of the code you need and the links to the documentation, where everything is thoroughly described with screenshots and examples. All you're left to do is adapt these examples to your specific use-case.

Though, if you'd like us to assist with your app development, we'd be happy to provide our consulting services.

photo
1

thank for help

If i connect users with their group .if every time i have to repaet that manule . how to automaticly connet to user with there group

photo
photo
1

If i connect users with their group .if every time i have to repaet that manule . how to automaticly connet to user with there group

photo
1

This is described in the same documentation as well: https://backendless.com/docs/android/doc.html#dynanchor9

With samples and screenshots.

photo