Please create an account to participate in the Slashdot moderation system


Forgot your password?
Programming Books Media Data Storage Software Book Reviews IT Technology

MySQL: Building User Interfaces 266

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 Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.

This discussion has been archived. No new comments can be posted.

MySQL: Building User Interfaces

Comments Filter:
  • MySQL Feature Set (Score:4, Insightful)

    by Saeed al-Sahaf ( 665390 ) on Thursday February 05, 2004 @06:05PM (#8194882) Homepage
    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.
  • Interesting Book (Score:5, Insightful)

    by saberworks ( 267163 ) on Thursday February 05, 2004 @06:08PM (#8194910)
    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.
  • Silly comment (Score:3, Insightful)

    by Rosco P. Coltrane ( 209368 ) on Thursday February 05, 2004 @06:10PM (#8194933)
    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

    Since when do people read computer books on the throne? I would think anybody who's interested in this book (yes, you two hiding at the back!) would be reading it in front of a computer, trying out the sample code to learn what's going on.
  • Re:Try SQLite (Score:3, Insightful)

    by cscx ( 541332 ) on Thursday February 05, 2004 @06:17PM (#8195015) Homepage
    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.
  • Yes but... (Score:2, Insightful)

    by anonymous coword ( 615639 ) on Thursday February 05, 2004 @06:21PM (#8195047) Homepage Journal
    Would you *reallY* like users installing MySql on their machines with the easiest to use options (read:insecure options) by default? GUIs are much worse. Best to stick with raw SQL and text files, that way you *have* to learn to secure the system.
  • Re:Try SQLite (Score:2, Insightful)

    by hendridm ( 302246 ) on Thursday February 05, 2004 @06:22PM (#8195058) Homepage

    > I suppose the app could easily be written to start the server when it starts and shut the server down when it ends

    True, but besides being sort of hokey, the requirement of having MySQL installed might not be ideal if your target audience isn't savvy enough to install it, or perhaps don't want extra, normally unnecessary, stuff on their computer. I guess it all depends on your needs and target audience.

  • by Moth7 ( 699815 ) <> on Thursday February 05, 2004 @06:25PM (#8195088) Journal
    But do we really want the book to only scratch the surface in many languages rather than give it thoroughly indepth with a single language? I often find it frustrating when chapter upon chapter is dedicated to a language I'll never use. If however you want lots of other languages covered, the MySQL Cookbook [] by O'Reilly has good scenario based discussions of using MySQL with PHP, JSP (as you wanted) as well as Python and Perl.
  • by gbrayut ( 715117 ) on Thursday February 05, 2004 @06:26PM (#8195104) Homepage
    Just wondering why you wanted to get away from the web interface? If done correctly, isn't a web interface much better then a client/app, since it provides a single interface that works on all operating systems and from all locations?
  • by BinaryCodedDecimal ( 646968 ) on Thursday February 05, 2004 @06:31PM (#8195152)
    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...
  • by _fuzz_ ( 111591 ) <me AT davedunkin DOT com> on Thursday February 05, 2004 @06:31PM (#8195153) Homepage
    Actually, subqueries are only supported in 4.1, which is not considered production level. So there still isn't a production-quality MySQL server that supports subqueries.
  • Re:Try SQLite (Score:2, Insightful)

    by laird ( 2705 ) <> on Thursday February 05, 2004 @06:31PM (#8195162) Journal
    "This is why MySQL will *never* be a replacement for Access, despite what I often see on slashdot."

    That's true -- it would be more accurate to describe DBM as a replacment for Access, and MySQL or PostgreSQL as a replacement for SQL Server.
  • by lawpoop ( 604919 ) on Thursday February 05, 2004 @06:38PM (#8195224) Homepage Journal
    Couldn't the author have made a little more recent comparison to database technologies? AFAIK, SQL server is at version 2k, and Access at version 2k3.
  • by Carl T ( 749426 ) on Thursday February 05, 2004 @06:38PM (#8195227) Homepage
    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.
  • Re:Try SQLite (Score:4, Insightful)

    by cscx ( 541332 ) on Thursday February 05, 2004 @06:41PM (#8195251) Homepage
    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).
  • by t_pet422 ( 613073 ) on Thursday February 05, 2004 @06:43PM (#8195260) Homepage
    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.
  • Move? (Score:4, Insightful)

    by ClosedSource ( 238333 ) on Thursday February 05, 2004 @06:45PM (#8195282)
    "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.
  • by ttfkam ( 37064 ) on Thursday February 05, 2004 @06:49PM (#8195336) Homepage Journal
    ...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.
  • by geoffspear ( 692508 ) on Thursday February 05, 2004 @06:55PM (#8195422) Homepage
    That would be easier if the reviewer wasn't reviewing a book that was published 3 years ago.
  • by Tassach ( 137772 ) on Thursday February 05, 2004 @07:00PM (#8195476)
    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 []. It doesn't come with source, but come on now, how many MySQL zealots have ever even compiled from source, let alone modified something?

  • by JanneM ( 7445 ) on Thursday February 05, 2004 @07:06PM (#8195527) Homepage
    Acutally, I have yet to need a "full-featured database". From what I've seen of various apps, neither do most other people. By and large, most apps needing a form of database storage usually get by with DBM or equivalent functionality. 'Real', big database applications that need the kind of stuff you mention are few and far between - and in those cases, there are plenty of alternatives anyhow, like you say.

    For me, MySQL is not a deficient implementation of the Likes of Oracle, but a full-featured, modern way of accomplishing what DBM did.

  • by EastCoastSurfer ( 310758 ) on Thursday February 05, 2004 @07:18PM (#8195653)
    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.

    I have to agree here. I was using MSSQL the other day and was able to open an XML document inside a stored proc and query it like it was a table. All I could say was "Damn, that's pretty cool!"

    I had been using the FOR XML EXPLICIT quite a bit for output, but didn't (until recently) need to read XML back into the database.
  • by ttfkam ( 37064 ) on Thursday February 05, 2004 @08:01PM (#8196089) Homepage Journal
    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 (
    num1 INT,
    num2 INT NOT NULL,
    num3 INT
    price NUMERIC(4,2),
    code VARCHAR(8),

    'A quick brown dolphin...',
    ); 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?

  • Re:Try SQLite (Score:3, Insightful)

    by ttfkam ( 37064 ) on Thursday February 05, 2004 @08:37PM (#8196494) Homepage Journal
    Even with an O(n) scheduler, an idle daemon is nothing. While some others may be impressed with your use of Big-O notation, many of us are not. Even an O(n^2) algorithm isn't that bad if your dataset is sufficiently small. The O(1) scheduler is a glorious thing only because the number of processes (forks, threads, etc.) reaches very high amounts on a large, loaded system. At hundreds of thousands of processes/threads, the choice of scheduler makes a big difference in overhead. And for that matter, if the number of processes without an idle RDBMS running is 100,000, and the RDBMS pushes it to 100,005, the scheduler isn't going to care. It'll be highly unlikely that you could reliably measure a difference.

    At smaller numbers (one or two hundred), who cares? Your server isn't using 100% of your resources (CPU or otherwise). They are just going to waste if there's no RDBMS loaded. ;-)

    This argument is old. It's like the assembly vs. C debates in the seventies. ...and just as clear cut. "Premature optimization is the root of all evil." Works for system administration as well as software engineering. The real question isn't "which is more efficient?" The real question is "which gets the job done faster?" If I can start a RDBMS and walk away, that constitutes "faster" to me.
  • Re:Locking Problem (Score:3, Insightful)

    by LuxFX ( 220822 ) on Friday February 06, 2004 @01:49AM (#8198610) Homepage Journal
    from the sql lite page it looks like multiple users can select silmultaneously but only write to the database one at a time.

    I don't see this as a problem, because at least I see SQLite as more of a portable pre-packaged data structure, rather than a traditional multi-user database. I haven't had a chance to use it yet myself, but I look forward to using it in stand-along applications where I need good data structure and the ability to filter and search for specific data. I'm a fair hand with MySQL, so having all of this wrapped up into a SQL-compatible package is exactly what I need.

    It means I get to concentrate on what I find more exciting about programming -- rather then spend a load of my time on file structure and data processing.
  • by Anonymous Coward on Friday February 06, 2004 @02:34AM (#8198861)
    Who writes INSERT statements without giving field names? And if you don't know your table structure and what you are putting into it, then you deserve the anquish to come.

    I do database work with MySQL and SQL Server 2000. All functions I write check that the data I'm getting or putting to the database matches the data type. It's a little extra legwork, but I don't carry a pager for dumb mistakes that can be avoided either.

    Never throw data at your DB like as parent poster describes above.
  • I am in awe (Score:3, Insightful)

    by ttfkam ( 37064 ) on Friday February 06, 2004 @03:59AM (#8199118) Homepage Journal
    I've just pointed out that the salad has roaches and rat feces in it and someone steps up to chastise me for using the wrong fork.

    INSERT INTO test
    (id, num1, num2, num3, price, code)
    VALUES (
    'A quick brown dolphin...',

    Now the syntax should be kosher. ...and MySQL still acts like a brain dead cat on crack.
    All functions I write check that the data I'm getting or putting to the database matches the data type.
    And I applaud you for that. It's good to know that you never make mistakes, are always fully rested, are never up against a hard deadline, etc. I'm not questioning your coding skills or your intelligence. On the contrary, I think that extra checks are always worth it. What I am saying is that the database, the final repository for your data, should be making at least the same amount of effort.

    When the string 'A quick brown dolphin...' is passed to an integer field because I'm overly tired, a collegue hasn't been as rigorous as I usually am, some crack-smoking intern had a brain fart, or whatever, the fact remains that MySQL detected that it wasn't an integer. It didn't try to throw it in as the first 32-bits of the binary string. The table needed a number, MySQL had no idea what number you meant, and it decided to put in the default value for the column according to its datatype. In other words, it placed a value that I didn't explicitly specify through the client or schema and did not warn the client that it had done so.

    Imagine if all of those POSIX networking functions didn't return an error code. Why not? I'm sure there are folks out there who will say, "But my network is always up, the cables are of highest quality, and in all the time I've worked there, I have never had a socket connection fail; so why do I need the error code back?" No matter the preparation, no matter the training, no matter how good the conditions are, when the rubber hits the road, I would like to be able to see out of the windshield to see if I've spun out.

    This is the salient point that people (including the pager-adorned gentleman in the parent post) appear to blithely ignore. It's the giant pink elephant in the corner that everyone notices but no one wants to talk about.

    By all means, perform the extra checks. Perform a check at compile time, at deploy time, and at runtime. Why are MySQL folks so averse to having a check at insert/update time as well? Why is it such an affront to want your database to do its own data integrity checks? Why is it so horrible to expect a relational database to do its job!? I honestly want to know. I would very much like some insight into this rather than picking on my choice of salad fork.

"You must have an IQ of at least half a million." -- Popeye