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