[Kansas-general] virtual tables

Berger, Daniel djberge at qwest.com
Fri May 14 13:14:42 EDT 2004


I was just thinking that it would be cool if you could create a virtual
table with the table method.  For now, you can do something like:

ksdbh.table(:Students,:students), and this creates a Students class with
all the records from the students table.

What if we allowed the table method to accept a block to define what
data we want back in our class?  For example:

ksdbh.table(:VStudents,:students){ students.student_id < 100 }

This would create a "virtual" class VStudents, that only contains
students with a student_id less than 100.  So, what you end up with is
what amounts to a view based on a single table.

If we continue along these lines, we could allow the table method to
accept an array of table names and build a multi-table view.  For

   students.student_id > 100
   students.student_id = :student_data.student_id

So, now we end up with a slightly more realistic view, mapped to our

Whaddya think?


More information about the Kansas-general mailing list