Slashdot Mirror


MySQL: Building User Interfaces

Craig Maloney writes "If you are a Windows programmer looking to create or move your stand-alone database applications away from Microsoft-specific tools such as Visual Basic, Visual C++, Access or SQL Server, MySQL: Building User Interfaces is written just for you." Read on for the rest of Craig's review. MySQL: Building User Interfaces author Matthew Stucky pages 632 publisher New Riders rating 4/10 reviewer Craig Maloney ISBN 073571049X summary MySQL and GTK+ are used to create cross-platform applications, with copious code listings.

What's in the book? The first chapter guides the reader through the basics of MySQL and how it compares to Access 2000 and SQL Server 97. Next, a code listing demonstrates the basics of connecting to MySQL via C using the MySQL C API. the book gives an all-too-brief whirlwind tour to the basics of MySQL. The next four chapters are a tutorial on how to use GTK+ and GLADE, focusing on how these toolkits are similar and different from their Visual Basic counterparts. GTK+ was chosen in this book because of its cross-platform compatibility with both Windows and Linux / UNIX operating environments. The second part of the book takes what was learned about MySQL and GTK+ with GLADE and uses it to create a stand-alone application (a real-world order-entry application). What's Good? Throughout MySQL: Building User Interfaces, Stuckey describes exactly what he is doing and why he is doing it that way. The introduction to GTK+ in the first part of the book describes just about every GTK+ widget available (menus, buttons, sliders, status bars, etc.), and creates a monster busy-box application (not to be confused with the busy-box application by Bruce Perens) demonstrating those widgets by themselves. Later in the book Stuckey uses Glade to put applications together, but not using Glade early on gives the reader a chance to see what is happening under Glade's abstraction. During the building of the order-entry application, Stuckey explains the design decisions behind the widgets. Each window of the application is introduced first with a diagram describing where the widgets will be followed by the code for each widget. The design looks like a Visual Basic application designed by a a programmer, with an eye toward the functional rather than the aesthetics of user interface design, but as an introduction to GTK+ programming it works well. What's Bad? If there was ever a book that required a CD-ROM to accompany it, this book gets my nomination. Authors have to walk a fine line between presenting code snippets that don't make sense by themselves, or risk boring readers with page after page of code that might confuse readers who aren't yet ready to view full code listings. MySQL: Building User Interfaces chose to include the full code listing for everything. This is both a blessing and a curse: readers have the code right in front of them and don't have to worry about being in front of a computer while reading the book, but the flow of the book is interrupted every time something is introduced.

The descriptions also suffer, because those code listings are expected to explain in more detail what is going on. In the GTK+ introduction, widgets are introduced with short paragraph introductions. The real-world application, which should be the focus of the book, reads like an assembly line: A screen is introduced, the widgets are placed, and the code is listed. Worse, files which make little sense without a computer (such as files generated by glade) are presented along with the code listings. This makes reading this book a chore. Thankfully, there is an FTP site with the code ready to use, but future versions of this book would be best served to include it on disc.

Perhaps a balance can be struck in a future edition where important code concepts are highlighted without sacrificing seeing the code in a meaningful context.

So, what's in it for me? Windows programmers who need a hand in getting their applications to Linux or UNIX may find this book helpful (but overwhelming) as they learn. This book stands out as a bridge for Windows programmers to make their transition to Linux and UNIX smoother, but the emphasis and amount of code listings in this book may make Windows programmers choose a different route.

You can purchase MySQL: Building User Interfaces from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.

31 of 266 comments (clear)

  1. Try SQLite by hendridm · · Score: 4, Informative

    MS Access has the advantage (on Windows machines anyway) of being a stand-alone database without needing a service to be installed. For a app where you don't want to have to install MySQL server and have it waste resources, you might consider SQLite. Unlike MySQL embedded, it's release under the public domain. MySQL Embedded is licensed under the GPL and has the following requirement:

    ... any program which includes, by linking with libmysqld, the MySQL source code must be released as free software (under a license compatible with the GPL).

    Although, depending on what you want to do with the software, this may not be a problem. I'm all for free and open source software, but a brother's gotta eat too.

    1. Re:Try SQLite by man_of_mr_e · · Score: 3, Informative

      Access is simply an application. When you open the database, it's just like opening a file in a word processor.

      MySQL is a service that runs seperately from the application and must be started and stopped seperately. In most cases, the service is started at boot time and runs all the time, wasting resources unless you manually stop it.

    2. Re:Try SQLite by cscx · · Score: 3, Insightful

      An Access database (usually a .mdb file) is just a binary file. Your application uses the Access DB driver to read/write to this file.

      MySQL on the other hand (which may consist of multiple binary files) has to run a daemon (i.e., server) to be accessed. Your application uses the MySQL driver to talk to the MySQL daemon, either through TCP/IP or a local socket.

      This is why MySQL will *never* be a replacement for Access, despite what I often see on slashdot. You can fit a small Access database on a floppy. Conversely, you may need a full fledged DBA to run MySQL.

    3. Re:Try SQLite by Mod+Me+God+Too · · Score: 4, Informative

      I do a little DB development. The basic difference is a DB system like MySQL, Oracle or SyBase is that the 'DB' is the back-end (indeed it is a server-type process) which is interrogated by SQL statements (the front end may be built in C++, VBA, whatever), whereas something like Access is an all-in-one solution with the back-end and the front-end in the same app mish-mashed together (it may purport to be SQL-like, but only from within the app, not as a server) - I think MS still provide Foxpro as Access simple can't hack really big work. So an SQL-type database is the classic client-server, Access and Paradox don't seperate front and back ends (they say they can be split, but that is a bit of a bodge job).

      Wikipedia has a more thorough discussion here (for SQL) and here (databases in general but quite a read)

      --
      --

      It is not the commies, the government, the nigger, nor the corporates. It is your paranoia.
    4. Re:Try SQLite by jcoleman · · Score: 5, Funny

      I'm all for free and open source software, but a brother's gotta eat too.

      Hope you like Indian food!

      Coleman

    5. Re:Try SQLite by Frymaster · · Score: 4, Funny
      he service is started at boot time and runs all the time, wasting resources unless you manually stop it.

      right. think "daemon".

      microsoft just uses the word "service" because sco owns the word "daemon".

    6. Re:Try SQLite by cscx · · Score: 3, Informative

      Actually, I think you may have been mislead if I read you correctly. Another person in the thread was correct when they said that Access is a front-end to the actual Access database. You can run SQL queries against an Access database... the functionality is built into the driver.

    7. Re:Try SQLite by cscx · · Score: 3, Insightful

      Are you aware that the data in a MySQL database can be ripped out to a file with the mysqldump command? Okay, perhaps passing it through bzip2 or similar will improve the odds of fitting it on a floppy.

      Well obviously, I too can do a text export of Access and gzip it as well! But that doesn't, uh, help the situation.

      And an Access database in an MDB file is hardly standalone, you still need a machine running Access to get much use out of it.

      Wrong. You don't need Access to create/update/use an Access database. The functionality it built into Windows (actually part of a bigger module called Jet).

    8. Re:Try SQLite by Narcissus · · Score: 3, Informative

      MySQL Connector/C++ (the C++ API from MySQL) is LGPL.

      So long as you link it correctly, you do not need to release the source code to your application: no matter how confusing the licencing on the MySQL website is...

  2. more sellers by tedtimmons · · Score: 3, Informative

    amazon link

    isbn.nu link

    half.com link

    No affiliate tags are used above. But here's the amazon link with my tag, if you feel generous.

  3. MySQL Feature Set by Saeed+al-Sahaf · · Score: 4, Insightful

    Before all the naysayers start in on what a flaky database MySQL is, how it doesn't do this or that, that it just a toy, please visit their web site and see what its current feature set is.

    --
    "Who are in control, they are not in control of anything - they don't even control themselves!" - Glen Beck
    1. Re:MySQL Feature Set by Anonymous Coward · · Score: 3, Informative

      another interessting read is here.

  4. Make sure you use MySQL version = 4.0 by spun · · Score: 4, Informative

    Before that, the dang thing doesn't support nested subqueries, or any kind of subqueries on inserts and deletes. Found that out the hard way recently (the docs don't make it very clear) and had to rewrite a bunch of elegant SQL as less elegant Perl loops and wacky joins.

    Still, I love MySQL. Postgres is more full featured, but for the smallish web-based applications I write, it's overkill.

    --
    - None can love freedom heartily, but good men; the rest love not freedom, but license. -- John Milton
    1. Re:Make sure you use MySQL version = 4.0 by ttfkam · · Score: 5, Insightful
      And it provides so little in the way of data integrity, that you'll have to spend that much more time adding the necessary functionality into your app layer.

      Example? Okay, whip out your MySQL client and type with me...

      CREATE TABLE test (
      id INT NOT NULL AUTO_INCREMENT PRIMARY_KEY,
      num1 INT,
      num2 INT NOT NULL,
      num3 INT
      price NUMERIC(4,2),
      code VARCHAR(8),
      );

      INSERT INTO test VALUES (
      0,
      99999999999999,
      NULL,
      'A quick brown dolphin...',
      21474.83,
      'ABCDEFGHIJK'
      );

      ...now after this, it should have given you a message like:
      "Query OK, 1 row affected"

      Seems to me that the data was a collection of square pegs to round holes, but MySQL never even dropped a warning.

      So let's check out that table again:

      SELECT * FROM test;

      1 row with the following is returned.

      id: 1
      num1: 2147483647
      num2: 0
      num3: 0
      price: 999.99
      code: ABCDEFGH

      Now stop. Take another look at the table definition. Take another look at the inserted data. Take another look at the output. Take another look at what has been stored in your database. Let's sum up: your primary key (your lookup key!) is not what you expected, the numbers are all different from what you entered, the price does not conform to your data schema (should be a maximum of 99.99), and your character string has been truncated...ALL WITHOUT AN ERROR OR WARNING.

      More examples at MySQL Gotchas. All of this in MySQL v4.0 and above. None of this crap happens in Firebird 1.5, PostgreSQL 7.x, or any popular closed source relational database.

      ...and it is crap. You have crap data in your database, and MySQL never let you know. For those of you out there who never ever write code with bugs, there's no problem; Go on ahead using MySQL. (Then again, you're in high demand for senior, very well paying jobs using Oracle or DB2 in Fortune 100 companies if that's the case.) For all the other folks out there (which includes everyone out there doing web development with dynamically typed languages like Perl and PHP), MySQL will happily insert crap data.

      And yes, there's a PostgreSQL Gotchas page. Tables are lowercase by default, and it requires the "AS" keyword for column aliases. Look at that list for PostgreSQL. Look at that above example. Can someone say with a straight face that these lists are comparable? Can someone say with a straight face that they want to explain to the computer-phobe why they got 2147483647 in their data? Can someone say with a straight face to their boss that these errors are acceptable in a production environment?

      --

      - I don't need to go outside, my CRT tan'll do me just fine.
  5. Interesting Book by saberworks · · Score: 5, Insightful

    I read most of this book (maybe an older version?) last year. I found it very interesting because it basically gave me the idea to let the staff members of my web site update the site through a windowed interface as opposed to a web interface. MySQL doesn't have to be running on the same computer as the program is running on, so this would be simple. That way you could provide a rich client (for staff members, not end-users) to update a web site based on MySQL.

    I know, it's not an original idea, but it's interesting because the book was a nice, step by step guide to doing just this. For what it's worth, I enjoyed it.

    On the other hand, I ended up spending time with XUL instead.

  6. Kexi is also worth checking out. by anonymous+coword · · Score: 4, Informative

    It is an open source program similar to Microsoft Access. It works with MySQL too. It even runs on Windows.

  7. Re:Suprised that the Review didn't mention this by Negative+Response · · Score: 3, Funny
    From the story:
    Thankfully, there is an FTP site with the code ready to use, but future versions of this book would be best served to include it on disc.

    Did you read the second half of the sentence, but failed to notice the first half?

  8. I read this book by Anonymous Coward · · Score: 3, Informative

    Recently I had to write a mysql demo for a tradshow. I had
    never worked with mySQL before. I got this book and was
    able to complete a full fledged demo in a matter of three
    days, working part time. The book is very well organized,
    easy to read and understand and best of all the examples
    work without modifications. I highly recommend this book
    for beginners. I would have done so for all levels but
    I'm not an advanced user of mySQL.

    If you're thinking of getting started on mySQL this is the
    book.

  9. Good book by TechnologyX · · Score: 3, Funny

    I have this book on my desk currently, its definitely a good resource on using MySQL for programs. The only gripe I had with it was that it didn't come with the source code, like was said in the review. I like how it focuses on converting the VB programmer over to GTK conventions.

    Maybe someone should send Mike Rowe a copy after he gets out of Redmond-Training.

    --
    Slashdot sucks
  10. Locking Problem by stoolpigeon · · Score: 3, Interesting

    from the sql lite page it looks like multiple users can select silmultaneously but only write to the database one at a time. Locking for writes is not record level, page level or even table level - it is the whole database.

    Too bad- because MySQL really does not replace Access but neither does this- unless it will only run internally to one user.

    --
    It's hard to believe that's how Micronians are made. Why don't we see it right now by having you both kiss one another?
  11. Re:windows developers by BinaryCodedDecimal · · Score: 4, Insightful

    if you are a windows programmer then you must be retarded

    I know many retarded people that would be offended by that statement.

    Seriously though, making sweeping statements like that just makes it obvious that you were never good enough for the high school debating team...

  12. A bit easier than programming GTK directly... by tcopeland · · Score: 3, Interesting

    ...might be to use a higher level language wrapper like Ruby/GTK.

    Prototyping an app will probably take less time if you don't have the compile/link cycle... worth a try, anyhow.

  13. Re:windows developers by Carl+T · · Score: 3, Insightful

    Don't confuse stupidity with lack of political engagement / ethics / knowledge / possibilities. I know quite a few people who are more or less stuck with Windows for various reasons (the main one being their employers' decision to - willingly or not - support Microsoft), but who would like to learn more and be able to break free. If a book like this can help even a few people gain some of the skills they need to migrate, it's a good thing.

    --

    This signature is not in the public domain.
  14. Why does OSS love MySQL? by t_pet422 · · Score: 4, Insightful

    I don't get why so many people are stuck on MySQL. It's lacks some very, very basic features: Views, Triggers, Stored procedures, nested selects. Sure, they promise support for all this in future version, but PostgreSQL supports it NOW. If you want a full-featured open source database, don't use MySQL, use Postgres.

    1. Re:Why does OSS love MySQL? by Tassach · · Score: 4, Insightful
      I too wonder about the inexplicable popularity of MySQL. It fills the microscopic niche between a lightweight ISAM database and a real full-featured relational database. I've yet to see MySQL used for something that couldn't have be done better with another tool.

      Postgres is pretty good, but still (IMHO) not yet up to the level of a commercial RDBMS. If you want a full-featured free-as-in-beer datacenter grade database, use Sybase 11.0.3.3. It doesn't come with source, but come on now, how many MySQL zealots have ever even compiled from source, let alone modified something?

      --
      Why is it that the proponents of "one nation under God" are so eager to get rid of "liberty and justice for all"?
  15. Move? by ClosedSource · · Score: 3, Insightful

    "If you are a Windows programmer looking to create or move your stand-alone database applications away from Microsoft-specific tools such as Visual Basic, Visual C++, Access or SQL Server, MySQL: Building User Interfaces is written just for you."

    Very few Windows applications are written in 'C' these days so converting an existing application to use MySQL would be pretty painful. You should have a better reason to port your code then simply avoiding MS tools.

    Perhaps the book is better suited for developers who wish to switch to Linux for future development.

  16. Both are replacements for MS SQL Server by ttfkam · · Score: 4, Insightful

    ...if you don't use transactions, stored procedures, triggers, views, sequences (read: real ones), or if you actually want your database to be typesafe and have your insert/update to throw an error (or at least a warning!) on invalid data. Otherwise MySQL is most certainly not a viable replacement, although the codebase which used to be called SAPDB is. Firebird also qualifies for a replacement.

    Also, if you need advanced XML querying tools for your database, none of the open source RDBMSs can currently act as a reasonable drop-in replacement for MS SQL Server.

    If you don't need any of those features (and especially haven't actually used any of them in existing code), then MySQL could be added to the list of open source RDBMSs that fit the requirements for your project.

    --

    - I don't need to go outside, my CRT tan'll do me just fine.
    1. Re:Both are replacements for MS SQL Server by Valar · · Score: 4, Interesting

      MySQL has transactions. It has for QUITE awhile. In fact, I write code that uses MySQL transactions everyday. Stored procedures are availible (will be availible?) in version 5.

    2. Re:Both are replacements for MS SQL Server by damiena · · Score: 4, Funny

      Firebird? It can do databases, too?

      That browser can do everything!

    3. Re:Both are replacements for MS SQL Server by ttfkam · · Score: 3, Interesting

      For varying definitions of "quite a while." Other than that I would agree with you except for the fact that every table involved in the transaction must be an InnoDB table. Have a half-and-half setup? When that transaction rolls back, the InnoDB tables will remove the changes, but the MyISAM tables will still be changed. ...not that MySQL will tell you this. No. Once again, it will do it all silently without even a warning to let you know that you need to convert one more of your MyISAM tables to InnoDB.

      Which doesn't even cover the fact that if you are being hosted by an ISP, using their copy of MySQL, and you type in:

      CREATE TABLE foo (
      ...
      ) type=innodb;

      and they are either (a) running an older version of MySQL or (b) disabling support for InnoDB tables because of their noticeably higher overhead than MyISAM (yes, both cases happen quite regularly), you will be none the wiser.

      MySQL will not issue a warning, error, or valentine's day card for your troubles. So here you are, happily SQLing away without a care because you have InnoDB tables until you notice some strange data...because...you aren't running InnoDB tables after all.

      Be honest, how often do you run the following?

      SHOW CREATE TABLE foo;

      Everytime you create a table? No?

      How about the next statement? Here we attempt to give some users on Slashdot 10% more of a clue.

      UPDATE slashdot_users SET (clue = (clue * 1.1)) WHERE preferred_db = 'MySQL';

      and (oops!) something went wrong halfway through for some reason. Maybe someone killed the process. Maybe someone kicked a cord. Maybe you ran out of memory on the box and the process crashed. The world is an imperfect place. Back to work though: how many Slashdot users had their clues upped? If they were updating a MyISAM table that "didn't need transactions," we have no idea.

      Transactions aren't just BEGIN and END statements. They aren't just commit() and rollback() functions. They are intrinsic to a valid datastore. They are the Atomicity in ACID. That UPDATE statement was a transaction in all contexts used to describe databases.

      MySQL and transactions are like assembly language and for-loops. They can be made to go together, but they were not originally designed for such a task. In assembly, it's a set of well-placed jump (goto) statements. In MySQL, it's a set of table=innodb flags. Some people do it the hard way for no good reason even when easier, less error prone methods exist. For the rest of us, we use a higher-level language or -- in this case -- a higher-level database. If and only if we see a need to optimize do we drop down to assembly (MySQL). You don't start with assembly and then try to find rationales for a higher-level language.

      --

      - I don't need to go outside, my CRT tan'll do me just fine.
  17. Use Access as a GUI for mySQL! by Mr.+Cancelled · · Score: 5, Informative
    For a content management system I've developed, I prototyped all of the basic functionality by using Access as a GUI for mySQL. And I loved it! I actually considered doing the whole thing this way for a bit as it offered so many of Access's strengths (quick and powerful GUI building, familiar environment, everyone has it, etc.), but was combined with mySQL's stability, scalability (Well... For the needs of my target audience at least), and versatility. All's you need to tinker with this is the free MyODBC package, and suddenly your mySQL database is seen as a standard ODBC one. You can build table relationships within Access using mySQL based source data. You can locate the mySQL server anywhere you want (local or remote), point Access at it, and there ya go. Additionally you can now use VBA within Access to take advantage of many Active-X components, as well as a wealth of freely available VB code. There were several reasons I went back to my original plan of just prototyping in Access, and deploying via a web-based setup:
    1. Obviously not everyone has Access. Many do, or have access to it via work or school (access to Access?!?)
    2. There were certain things that were easier to implement in an HTML-based setting (conversely, there's things I still can't equal that were accomplished easily using VB & Active-X. Things such as a customized file browser with a built in image viewer)
    3. While some of my VB code and Active-X'ing would have been transferable to the web, it would have required requiring that the user of my system use IE to administer it. Not gonna happen!
    4. I just don't like Microsoft enough to make my product only available to users of their software. The above IE example would have required my admins to IE; Access would require users to have Access; Having Access implies that the user must also run Windows (Wine just isn't there for Access usage I'm afraid. At least not for very advanced usage)
    But for other projects I have, who's target audience is Windows users, Access is a great way to quickly build some impressive mySQL-based applications. IMHO, of course. 8)=