I think Ikai means, that you dont really need a 'Department' table.

Just store "DepartmentName" directly as a string on your Employee model.


In a RDBS you traditionally 'normalize' - mainly to reduce database size.


In appengine and the datastore, you denormalize. Disk-space is 'cheap'
so duplicating the string in every record is not really an issue.

http://en.wikipedia.org/wiki/Denormalization


Appengine is based on the premise of write once, read many, to making
your queries 'lightweight' is important too. Completely eliminating a
join makes the query much quicker to run.



(unless you need to query on DepartmentName then you should make it as
not-indexed, otherwise it will eat up space in the indexes)



On Fri, Jun 17, 2011 at 4:21 PM, Bruce Aloe <[email protected]> wrote:
> The reason i need to join these two kinds is because i need to know
> the department name that the employee works at as you can see the
> query "List all employees's Id (EmployeeId), name (Name), salary
> (Salary)
> and their department name (DepartmentName) for the ones earns more
> than 8000 US dollar".
>
> In SQL, i could do the query like this:
> select  e.EmployeeId, e.Name, e.Salary, d.DepartmentName
> from Employee e, Department d
> where e.Salary > 8000
>
> That is why i need to join these two kinds.
>
> Bruce
>
> On Jun 16, 1:26 pm, "Ikai Lan (Google)" <[email protected]> wrote:
>> It's not clear to me why you need a join here. If you're just doing it by
>> Department type, why not make the "Department" field a String?
>>
>> Ikai Lan
>> Developer Programs Engineer, Google App Engine
>> Blog:http://googleappengine.blogspot.com
>> Twitter:http://twitter.com/app_engine
>> Reddit:http://www.reddit.com/r/appengine
>>
>>
>>
>> On Thu, Jun 16, 2011 at 3:30 PM, Bruce Aloe <[email protected]> wrote:
>> > Hello,
>>
>> > In a simple case, suppose i have two kinds (tables) stored in GAE
>> > datastore:
>>
>> > Employee (EmployeeId, Name, Salary, StartDate, DepartmentId)
>> > Department(DepartmentId, DepartmentName)
>>
>> > For Employee kind, EmployeeId is the unique key and DepartmentId is
>> > the join attribute for Employee to make join with Department kind. For
>> > Department kind, DepartmentId is the unique key. Both Employee and
>> > Department kinds have quite a lot of tuples, let us say, more than 3
>> > million tuples.
>>
>> > There is a need to make join query over both Employee and Department
>> > kinds in order to answer the query concerns the data from both kinds.
>> > For example a query could be "List all employees's Id, name, salary
>> > and their department name for the ones earns more than 8000 US
>> > dollar".
>>
>> > How can i make join query among different kinds to answer the query
>> > concerns different kinds?
>>
>> > Of course, there could be more than just two kinds stored in GAE
>> > datastore. If one wants to make join query among more than two kinds,
>> > how to handle that?
>>
>> > Thank you for your help!
>>
>> > Bruce
>>
>> > --
>> > You received this message because you are subscribed to the Google Groups
>> > "Google App Engine" group.
>> > To post to this group, send email to [email protected].
>> > To unsubscribe from this group, send email to
>> > [email protected].
>> > For more options, visit this group at
>> >http://groups.google.com/group/google-appengine?hl=en.- Hide quoted text -
>>
>> - Show quoted text -
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Google App Engine" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/google-appengine?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.

Reply via email to