[mythtv-users] Think table as Class and record as Object

David Rudder drig at noses.org
Fri Jan 13 15:23:08 UTC 2006


I think this is a good idea, but it's not as easy as all that. This is a 
fairly standard programming problem. The problem with simply modeling 
each table as a class is that it doesn't take into account foreign 
relationships. For instance, with the CardInput class, you'd want to be 
able to store a reference to the CaptureCard class, not just an integer 
CardID. So, you can say "CaptureCard card = cardInput.getCaptureCard()" 
and it will return a CaptureCard. Rather than having to say "CaptureCard 
card = database.loadCaptureCard(cardInput.getCaptureCard())".

I guess what I'm saying is that I think you have a good beginning here 
to make some very useful automation code, but you have to be careful 
that your classes match the data model, or it'll end up being difficult 
to use.

There's a Java project called Druid (available in Sourceforge. Search 
google for it). It'll automatically generate C, C++ or Java code for 
representing the data. It should help you get started.

Feel free to email me off line at
drig at noses dot org

-Dave

P.S. I also have 45 tables.
P.P.S. Once you have the database modeled in code, what are you going to 
do with it? Any cool tools?

YanJun Lu wrote:

> Hi All
> How many tables in your database of MythTV,As for me, There are 45 
> tables in my MySQL. I have a idea for that create Class for every 
> tables, Well, I mean that we can think table as an Class and record of 
> table as Object, So do my idea is good?
>
> ------------------------------------------------------------------------
> 雅虎1G免费邮箱百分百防垃圾信 <http://cn.mail.yahoo.com>
> 雅虎助手-搜索、杀毒、防骚扰 <http://cn.zs.yahoo.com>
>
>------------------------------------------------------------------------
>
>_______________________________________________
>mythtv-users mailing list
>mythtv-users at mythtv.org
>http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users
>  
>




More information about the mythtv-users mailing list