Results 1 to 2 of 2

Thread: Qt, Databases & the DAO Pattern

  1. #1
    Join Date
    Feb 2006
    Posts
    32
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Qt, Databases & the DAO Pattern

    I need to make a decision whether to use inline SQL directly using the QtSql module or develop Database Access Objects using the DAO Pattern. How does QtSql handle the differences between databases? I realise there is a hasFeature() method but it doesn't include things like views, triggers, etc, why is that?

    When I read about the DAO pattern I am very concerned about whether it actually works in the "real world"!

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt, Databases & the DAO Pattern

    DAO pattern comes from Java world and it's quite reasonable when you take into account all that code you need to write to read something from database using JDBC and the danger of resource leak when you forget to invoke dispose() (or whatever it's called) method on each of created objects.

    Another thing is that DAO provides a separation between data and logic. If your database schema changes, you would have to change only apropriate DAO classes instead of looking through your whole code. On the other hand it might lead to performance loss, as you would have to use more general queries. Of course you could use something in between.

    Anyway DAO (and QtSql module as well) won't save you from differences in SQL dialects. The best solution, IMO, is to use subset of SQL standard that is implemented by all DBMS that your application will use. I was thinking about other possibility too --- translating the SQL queries in the runtime depending on current database driver, but I'm not sure if it will be fast enough.

Similar Threads

  1. Publish Subscriber Pattern in Qt
    By donglebob in forum Qt Programming
    Replies: 9
    Last Post: 26th June 2013, 16:01
  2. pattern
    By mickey in forum General Discussion
    Replies: 3
    Last Post: 14th February 2009, 17:12
  3. dictionary databases
    By rishiraj in forum Newbie
    Replies: 1
    Last Post: 5th January 2009, 08:30
  4. Changing the Text Pattern?
    By ashukla in forum Qt Programming
    Replies: 13
    Last Post: 29th December 2007, 11:10
  5. two databases opened at the same time
    By whoops.slo in forum Newbie
    Replies: 5
    Last Post: 28th January 2006, 14:38

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.