Can i achieve that with joins?

On Thursday, 12 July 2012 01:20:50 UTC+2, Najtsirk wrote:
>
> Yeah...i noticed that from your previous answers :)
>
> But...what my other options?
>
> On Thursday, 12 July 2012 01:13:06 UTC+2, Massimo Di Pierro wrote:
>>
>> Not in a single query using dal. And to tell you the truth I do not like 
>> union too much. :-(
>>
>>
>>
>> On Wednesday, 11 July 2012 17:47:06 UTC-5, Najtsirk wrote:
>>>
>>> Hello,
>>>
>>> I have a database design dilema. I want to do a e-learning system for a 
>>> course. The course soould have severeal lessons, each lesson can be of 
>>> different type.
>>>
>>> Let's say we have following model:
>>>
>>> #for definiton of each course
>>> db.define_table('course',
>>>
>>> Field('title', 'string')) 
>>>
>>>  
>>>
>>>
>>> #for the video lesson
>>> db.define_table('video',
>>>
>>> Field('title', 'string'),
>>>
>>> Field('video_url', 'string'),
>>>
>>> Field('course_id', db.course),
>>>
>>> Field('weight', 'integer'))
>>>
>>>
>>> #for the tekst lesson
>>> db.define_table('text',
>>>
>>> Field('title', 'string'),
>>>
>>> Field('content', 'text'),
>>>
>>> Field('course_id', db.course),
>>>
>>> Field('weight', 'integer'))
>>>
>>>
>>> I know how to do this with a raw sql using UNION, like:
>>>
>>> db.executesql('SELECT title, course_id, weight FROM video UNION SELECT 
>>> title, course_id, weight FROM text WHERE course_id = *some_value* ORDER 
>>> BY weight')
>>>
>>> But i wondering if there is any way I can achieve that with DAL? Maybe I 
>>> should design the database model in a different way?
>>>
>>> Thank you for your replies, ideas, thoughts..
>>>
>>> Kristjan
>>>
>>>  
>>>
>>>
>>>  
>>>
>>

Reply via email to