Beta
×

Welcome to the Slashdot Beta site -- learn more here. Use the link in the footer or click here to return to the Classic version of Slashdot.

Thank you!

We are sorry to see you leave - Beta is different and we value the time you took to try it out. Before you decide to go, please take a look at some value-adds for Beta and learn more about it. Thank you for reading Slashdot, and for making the site better!

MySQL Cookbook

samzenpus posted more than 7 years ago | from the lets-get-cooking dept.

Book Reviews 64

Michael J. Ross writes "Of all the technical challenges faced by the typical experienced computer programmer, questions about syntax form a relatively small portion. This is especially true now that current coding editors and IDEs offer statement expansion and syntax checking. Rather, the most common type of technical challenge is understanding how to solve a specific data access or manipulation problem. Hence the growing popularity of programming "cookbooks," which are filled with "recipes," each comprising a concise statement of a focused problem, followed by a solution, with plenty of sample code to show how to implement it. For developers using the MySQL database system, the gold standard of such books is MySQL Cookbook, by Paul DuBois." Read below for the rest of Michael's review

Published by O'Reilly Media, the second edition appeared in November 2006. This new edition has been updated for MySQL version 5.0. The publishers have a Web page devoted to the book, where the visitor can find both brief and full descriptions of the book, an online table of contents and index, a sample chapter (number 5, "Working with Strings") in PDF format, errata (none reported as of this writing), and a way to post your own review on the O'Reilly Web site. There are also links for purchasing the book, or reading an online version, in the Safari Bookshelf program.

The bulk of the book's material is divided among 20 chapters, covering a wide range of topics: Using the mysql Client Program; Writing MySQL-Based Programs; Selecting Data from Tables; Table Management; Working with Strings; Working with Dates and Times; Sorting Query Results; Generating Summaries; Obtaining and Using Metadata; Importing and Exporting Data; Generating and Using Sequences; Using Multiple Tables; Statistical Techniques; Handling Duplicates; Performing Transactions; Using Stored Procedures, Triggers, and Events; Introduction to MySQL on the Web; Incorporating Query Results into Web Pages; Processing Web Input with MySQL; Using MySQL-Based Web Session Management.

Most of these chapters contain a generous number of sections, each serving as a recipe for a specific problem within MySQL. Two of the chapters have only four such recipes, but most have a dozen or more, with a few of them boasting more than three dozen recipes. Each recipe begins with a brief problem statement, and usually an equally brief solution statement, followed by a much more lengthy discussion, which contains the actual explanation of the solution, the sample code, and the expected output of that code. Some of the sections conclude with a mention of related recipes that could also be consulted.

This book, like so many other programming cookbooks, is weakened by the practice of offering a "Solution" subsection that consists of only one or two sentences — so terse and high-level that it provides, for all practical purposes, no solution to the reader. The actual solution is found in the "Discussion" subsection, which follows. This practice makes no sense. Because both subsections address the problem solution, they should be combined into a single subsection, naturally labeled "Solution." It appears that the purpose of the current Solution statements is to provide a terse summary. If so, then it should be labeled as such, yet still included within the new Solution subsection.

Despite this illogical division of each solution into two subsections, the content of the problem solutions found in MySQL Cookbook should be quite valuable, for several reasons: Firstly, the author has chosen the sorts of problems, within each category, that the MySQL programmer would typically encounter. No doubt this is a consequence of Paul DuBois being the author of a number of MySQL books, as well as one of the earliest contributors to the online MySQL Reference Manual. Secondly, the solutions work, and have been demonstrated to do so. Thirdly, the writing style is straightforward, which is characteristic of O'Reilly's titles. Fourthly, all of the problem solutions contain sample code and its output, which not only demonstrate the validity of each solution (as noted in my second point), but also allows the reader to see how the solution works simply by reading the material, and not having to type in the sample code to get the output within their own development environment — assuming one is even at hand, when reading the book.

The bulk of MySQL-related code in use today, was created not just to be accessed within a database client program, such as mysql, but instead from interpreted programming languages — especially those used heavily on Web sites. This is one area where MySQL Cookbook really shines, because it contains a large amount of sample code in Perl, PHP, Python, Java, and even Ruby. That is not to say that every code sample in one language has corresponding samples for all of the other languages; that would undoubtedly make the book much longer than it currently is, and probably unwieldy. But in cases where all of the languages are capable of expressing brief solutions, then they are included.

Regardless of whether the reader chooses the print or online versions, there are roughly two ways to make use of this book. If a programmer wishes to significantly increase their knowledge of what MySQL can do for them, and also increase their comfort level with utilizing those capabilities, then they might elect to read the book from stem to stern. Given that this would involve reading over 900 pages, it would certainly take some time for the average developer, but arguably could be time well spent. At the other end of the spectrum, the reader might elect to peruse individual sections that look interesting — particularly if they are relevant to a current project. This approach is certainly doable, because each of the recipes is self-contained, without the cross-referencing seen in many non-recipe style books. Admittedly, there are some "See Also" sections, but they are relatively few in number, with largely optional information, and tend to simply enrich the book's presentation, rather than frustrating the reader by pointing to other areas of the book.

This new edition of MySQL Cookbook concludes with four appendices, and an index. The first appendix explains where to obtain the software for MySQL, the five API programming languages used in the book, and the Apache Web server. The second appendix shows how to execute programs written in those five interface languages, on the command line. The third appendix is a fairly substantial primer on Java Server Pages (JSP) and Tomcat, providing an overview of servlets and JSP, as well as how to install and set up a Tomcat server, the Tomcat directory structure, the basics of JSP pages, and more. The last appendix lists resources outside the book for MySQL and the five aforementioned languages.

Unlike far too many programming books on the market now, this book's index is generally quite thorough, which is essential for a work of this size (975 pages). The recipe titles in the table of contents, are detailed enough to make it possible for the reader to locate the appropriate recipe in the book for their particular problem — assuming the book addresses that problem — and are grouped by subject, making it easier to find related recipes, which oftentimes can provide insight into other problems that they do not address directly.

Despite the obvious effort that has gone into both editions of this book, there are still some areas for improvement, and most of them are related to the readability of the sample code. Admittedly, there are different schools of thought as to optimal coding style, including use of whitespace, the placement of braces, and other matters. This assessment can only be my own opinion, based upon years of reading other people's code. The sample code in MySQL Cookbook would be more readable if more whitespace were utilized to separate function and variable names from open and close parentheses. This is especially true for the SQL code and MySQL extensions, for which all of the keywords are in all uppercase. The code fragments and full programs written in the API languages — such as Perl and PHP — are more readable, though they sometimes suffer from nondescriptive variable names. One might argue that the aforesaid choices are needed to cut down on the space consumed by the code on the book's pages. But if that were true, then the author likely would not have wasted an entire line for each open brace. Last, and certainly not least for the programmer who would like to try out the author's sample code in their own environment, it is unfortunate and inexplicable as to why the sample code is not offered on the O'Reilly Web site for downloading.

All in all, MySQL Cookbook is a well-organized and neatly written work, which should be of tremendous value to any software developer trying to find proven solutions to common database programming problems.

Michael J. Ross is a Web consultant, freelance writer, and the editor of PristinePlanet.com's free newsletter. He can be reached at www.ross.ws, hosted by SiteGround.


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

Sorry! There are no comments related to the filter you selected.

select * from posts where nr=first (0, Funny)

Anonymous Coward | more than 7 years ago | (#18211152)

or something

Re:select * from posts where nr=first (0)

Anonymous Coward | more than 7 years ago | (#18211434)

:: select name from slashdot_users where sexual_preference='hetero';
returned 0 rows

HAR HAR YOU MADE A FUNNY (0)

Anonymous Coward | more than 7 years ago | (#18212940)

HAHAHAAHAHAAH

Cookbooks take em or leave em they're OK (2, Informative)

JoeCommodore (567479) | more than 7 years ago | (#18211234)

I have the PHP Cookbook and there are many useful tidbits, but this axiom applies "there is more than one way to code an Application" so I find them more a good resource for ways to do things I didn't know existed, but not necessaily the way that best suits me or my needs.

I had a chance to skim through the MySQL cookbook a week or so ago and will more than probably pick one up, though I think I need another shelf for my web development/linux books. :-)

irCertaninly the ORielly programming series are very nice books indeed. Not quite used to their Linux OS books yet from them, the Wiley ones are more approachable.

Re:Cookbooks take em or leave em they're OK (2, Insightful)

truthsearch (249536) | more than 7 years ago | (#18211546)

I think your axiom is especially applicable to MySQL users. I've found MySQL performance tweaking to be as much art as science. There's never a one-size-fits all solution to any problem. Even if a book lays out a scenerio and a solution, quite often if your own situation is just slightly different the solution is very different.

I find these cookbooks more useful with things like PHP and Linux. Although I'm sure there are some good nuggets of information in this cookbook.

Safari (1)

mfh (56) | more than 7 years ago | (#18212444)

I had a chance to skim through the MySQL cookbook a week or so ago and will more than probably pick one up, though I think I need another shelf for my web development/linux books. :-)

I'd recommend trying their online library [oreilly.com] , which most certainly contains this book as well as about 10000 others on a wide variety of subjects, ATM. I used Safari last month and it was really amazing!! I plan on renewing my subscription when I have more reading time...

Re:Safari (1)

JoeCommodore (567479) | more than 7 years ago | (#18212700)

Problem with the on-line library is I need a network connection to access it. I have one of thier CDs "Web Programming CD Bookshelf "

        * Dynamic HTML: The Definitive Reference, 2nd Edition
        * JavaScript: The Definitive Guide, 4th Edition
        * Programming PHP
        * Web Database Applications with PHP & MySQL
        * PHP Cookbook
        * Webmaster In a Nutshell, 3rd Edition

It's a little dated (bought on clearance), but good, and it sits in my laptop's CD when I need to lookup something without access to a connection or my bookshelf. Another benefiot is it's in HTML so I can cut and paste code from the books into my editor.

Re:Safari (1)

A.Chwunbee (838021) | more than 7 years ago | (#18213396)

I can cut and paste code from the books into my editor.
Sahib, is very nice to be meeting the fallow Indian!

MY MySQL Cookbook (0)

Anonymous Coward | more than 7 years ago | (#18213368)

http://dev.mysql.com/doc/ [mysql.com]

RTFMS

'nuff said.

Stop wasting my time (-1, Offtopic)

Anonymous Coward | more than 7 years ago | (#18211260)

I want postgresql books.. oh wait, those are already available from the Postgresql site at no charge.

Good review! (0, Offtopic)

countSudoku() (1047544) | more than 7 years ago | (#18211350)

I'm wondering if there's an emphasis on security measures relating to web-app dev. I'll have to pop by the bookstore and thumb through.

Need to do that anyway, as my last O'Rly book (JavaScript Definitive Guide) has a split in the binding and does not have the nice "stay open" binding like some of the other newer titles. I really need to hold the books in had to see if it has binding issues, Amazon is not up to speed in that respect yet. ;)

inane introductions (1)

bfields (66644) | more than 7 years ago | (#18211448)

"Of all the technical challenges faced by the typical experienced computer programmer, questions about syntax form a relatively small portion. This is especially true now that current coding editors and IDEs offer statement expansion and syntax checking. Rather, the most common type of technical challenge is understanding how to solve a specific data access or manipulation problem. Hence the growing popularity of programming "cookbooks," which are filled with "recipes," each comprising a concise statement of a focused problem, followed by a solution, with plenty of sample code to show how to implement it. For developers using the MySQL database system, the gold standard of such books is MySQL Cookbook, by Paul DuBois."

Funnel paragraphs are overrated.

Re:inane introductions (1)

seaturnip (1068078) | more than 7 years ago | (#18214714)

Yeah, why mention syntax at all? And personally I encounter way more varied and difficult problems in my daily work than just figuring out how to access or manipulate data. Though, looking at the programs he feels are worth showing off [www.ross.ws] , suddenly his ignorance doesn't seem so surprising. Gee whiz, a calculator! Get back to me when you're tracking down race conditions in million-line programs, bub.

Semantics is unknown to many programmers (1)

alienmole (15522) | more than 7 years ago | (#18215844)

Yeah, why mention syntax at all?
It's because he doesn't understand the concept of semantics. Since "syntax" is the user interface to a programming language, many programmers don't realize that there's more to a language than syntax. They see a reference manual as just the definition of the syntax of the language, since to them, that's all a language is.

Not this kind of cook book? (2, Funny)

jo42 (227475) | more than 7 years ago | (#18211470)

SELECT recipe FROM cookbook WHERE ingredient = 'Refried Beans'

Re:Not this kind of cook book? (0)

Anonymous Coward | more than 7 years ago | (#18211670)

[pedant]
Based on your comment, it looks like your 'recipe' table only allows one 'ingredient'. Not going to have a lot of fancy recipes there.

I'd suggest you either list ingredients in another table and do a join, or at the least, put multiple ingredients in a field and do a "LIKE '%Refried Beans%'" instead of an "=".
[/pedant]

Re:Not this kind of cook book? (1)

Planesdragon (210349) | more than 7 years ago | (#18213974)

No, no, his problem is that all he's got is refried beans. He wants to know what he can do with them, and nothing else.

Re:Not this kind of cook book? (1)

felix rayman (24227) | more than 7 years ago | (#18214880)

I would assume that there is a cross reference table of the ingredients of each recipe, and that cookbook is a view the DBA created to stop the developers from incessantly whining about having to do joins.

Re:Not this kind of cook book? (-1, Flamebait)

Anonymous Coward | more than 7 years ago | (#18215850)

> I'd suggest you either list ingredients in another table and do a join, or at the least, put multiple ingredients in a field and do a "LIKE '%Refried Beans%'" instead of an "=".

Don't do this, or else Fabian Pascal will FUCKING CUT YOU.

This recipe is missing (4, Interesting)

El Cubano (631386) | more than 7 years ago | (#18211472)

I noticed there was a recipe which I'd like to see which was not covered. Is there a recipe for don't treat my data as garbage by default?

It was brought up in a reply [slashdot.org] to a comment here on Slashdot by Marten Mickos, CEO, MySQL AB. I've not heard if they managed to help out the people who are effectively forced into using MySQL but would rather not.

Re:This recipe is missing (1)

kv9 (697238) | more than 7 years ago | (#18213610)

+4, Interesting? the recipe is linked in your post. change the defaults.

Re:This recipe is missing (1)

Just Some Guy (3352) | more than 7 years ago | (#18216100)

+4, Interesting? the recipe is linked in your post. change the defaults.

A snippet from the post in question:

There's no way (that I can find) to completely turn off non-transactional tables. As I understand it, if I forget to tell it when creating a table to make it transactional, it's silently not. If a transaction involves even a single non-transactional table, the whole thing is non-transactional. This makes me nervous.

Where's the recipe for fixing that problem?

Re:This recipe is missing (1)

kv9 (697238) | more than 7 years ago | (#18217732)

Where's the recipe for fixing that problem?

it's right in the reply [slashdot.org] : use InnoDB by default. or how about this, don't forget to set the transaction flag. it's not rocket science and these aren't valid complaints either. it's just mindless MySQL bashing because "it doesn't work as I expect it to by default and I can't be bothered to tune".

Be realistic (0)

Anonymous Coward | more than 7 years ago | (#18214542)

If they started doing that, then they couldn't make all those pretty graphs showing how fast their "database" is compared to their competitors. But it also allows them to have checkbox compliance.

Too funny (0, Troll)

gregarican (694358) | more than 7 years ago | (#18211542)

A MySQL cookbook reminds me of something I would use in college while learning to live flat broke. Great ways to spice up the old Hamburger Helper, Macaroni and Cheese, etc. You gotta be kidding me. The last time I checked out MySQL was a couple of years ago and then there were so many gotchas I wondered how heavy CRUD production apps could consider such a DB. It's like the MySQL designers figured rather than enforce data integrity and reject invalid transactions they would just kinda guess what you wanted and then put something into the DB on your behalf.

Re:Too funny (0)

Anonymous Coward | more than 7 years ago | (#18216448)

Looks like the stupid masses using MySQL are also moderating on Slashdot.

Boring, but... (0)

Anonymous Coward | more than 7 years ago | (#18211576)

I sat in on his panel at Vancouver's PHP Conf. last month and found him pretty informative... if not a little bit boring while presenting it.

Of course it was the first or second panel of the day, I don't think many people can get too excited about statistical analysis queries of world wide PHP users at 8 in the morning.

Re:Boring, but... (1)

AutopsyReport (856852) | more than 7 years ago | (#18211704)

I don't think many people can get too excited about statistical analysis queries of world wide PHP users at 8 in the morning.

And you thought the morning erection of the Slashdot male was caused by what, women?

Re:Boring, but... (1)

drinkypoo (153816) | more than 7 years ago | (#18211960)

And you thought the morning erection of the Slashdot male was caused by what, women?

I was pretty sure it was pressure on the bladder brought on by consumption of too much jolt, bawls, or mountain dew in the waking hours.

Re:Boring, but... (0)

Anonymous Coward | more than 7 years ago | (#18214396)

/.'s don't sleep you insensitive clod!

mo3 0p (-1, Offtopic)

Anonymous Coward | more than 7 years ago | (#18211828)

declined= in market sharey. *BSD is

Sample Code Delays (1)

chromatic (9471) | more than 7 years ago | (#18211866)

Last, and certainly not least for the programmer who would like to try out the author's sample code in their own environment, it is unfortunate and inexplicable as to why the sample code is not offered on the O'Reilly Web site for downloading.

It usually takes a couple of weeks for authors to re-enter society to the extent that they can extract the sample code and massage it into a releasable form. (For me it takes months, but I'm a bad example.) I assume that's what happened here.

Re:Sample Code Delays (1)

PatPending (953482) | more than 7 years ago | (#18212674)

Re:Sample Code Delays (1)

chromatic (9471) | more than 7 years ago | (#18213688)

Yes; the book preface mentions that. We're working on either hosting the code on our site too or pointing to Paul's page from our catalog page.

Paul, are you well? Update the errata! (1)

PatPending (953482) | more than 7 years ago | (#18211896)

I've been emailing errata to Paul from two of his books over the span of several months now and he's simply not updating the on-line errata pages. For example, the errata page for "MySQL and Perl for the Web" hasn't been updated since 2006-07-25; since 2006-02-11 for "MySQL"; and "MySQL Cookbook, 2nd Edition" has no errata at all yet it's a 975 page book.

Paul, your writing is first rate and I love everything about your books. I hope you are well--and get the errata updated soon, please.

BTW: Paul literally writes his books--with pencil and paper. In a coffee shop.

Re:Paul, are you well? Update the errata! (1)

bjepson (994) | more than 7 years ago | (#18212256)

PatPending,

Thanks for collecting the errata. Could you post it to the errata page [oreilly.com] ? That way, it will go through "the system" (we'll forward it to Paul, he's say yea or nay, and the changes will make their way into a future reprint).

Re:Paul, are you well? Update the errata! (2, Informative)

PatPending (953482) | more than 7 years ago | (#18212486)

Well, since you bring up O'Reilly: I contacted Julie at O'Reilly on 2007-02-06 (ref. tracker number 697612) regarding "Ruby on Rails Up and Runnig" with the fact that I've submitted at least ten separate errata for that book (and I was only up to page 51) and nothing had been posted yet. (The errata pages haven't been touched since November 2, 2006.)

So, yeah, *I* can make the *effort* and take the *time* to do so, but I have to wonder "Why bother?" when no action is being taken to keep the pages up to date. Sigh.

Re:Paul, are you well? Update the errata! (1)

andrewsavikas (906434) | more than 7 years ago | (#18213628)

Hello,
We're actually in the middle of a systems overhaul for errata -- to provide faster response, quicker updates to electronic versions of content (current processes are unfortunately still tied to print-based workflow triggers), and a more useful interface for viewing errata. Unfortunately, that's meant temporarily diverting attention from processing current errata submissions. We're working through the backlog, but there will likely be delays for at least a few more weeks. We do track all errata submissions, and will be processing yours shortly.

Thank you,
Andrew Savikas
Director, Digital Content and Publishing Services
O'Reilly Media, Inc.

Re:Paul, are you well? Update the errata! (1)

Bloke down the pub (861787) | more than 7 years ago | (#18214004)

regarding "Ruby on Rails Up and Runnig"
Well if they can't get the title right, there's not much hope. Though what Scottish folk/rock bands have to do with programming escapes me somewhat.

Re:Paul, are you well? Update the errata! (1)

PatPending (953482) | more than 7 years ago | (#18214350)

Argh! My bad! My face is red with embarrassment!

Re:Paul, are you well? Update the errata! (1)

lp-habu (734825) | more than 7 years ago | (#18228994)

Interesting. I sent in a correction to "MySQL: the definitive guide" a few months ago (about ten, actually) and got an immediate acknowledgement. Yesterday I got another email saying that the errata had been updated to include my submission. I checked, and it's there.

Re:Paul, are you well? Update the errata! (1)

PatPending (953482) | more than 7 years ago | (#18234204)

Paul emailed me on Sunday, acknowledging all of my errata submissions over the past few months. So he *is* well and he has updated the errata. (And I found out that the MySQL Cookbook 2nd Ed. really does have zero errata--incredible for a technical tome of 975 pages!) Ahh, all is right with the MySQL universe!

Chapter 1: Install PostgreSQL... (0)

Anonymous Coward | more than 7 years ago | (#18211982)

Maybe the author should have spent his time writing about a better RDBMS.

VC looking for MySQL gurus in NYC (0)

Anonymous Coward | more than 7 years ago | (#18212152)

Check out Fred's blog post [blogs.com] where he's trying to find MySQL people.

Aways funny to see these removed-from-the-trenches guys who think the solution to making their startup spaghetti code perform is to bring in a database guy/gal. We all know how this goes... the startup's founders/coders stonewall the database pro because they don't want anyone to see how shitty their code is.

So yeah, it's a joke to think that someone's going to come in and make everything go faster now, but hey, good chance to grab some of that VC money before it goes away.

How do I do this (0)

Anonymous Coward | more than 7 years ago | (#18212706)

So, the most common question novice programmers have is 'how do i program'? Am I the only one who read the review like that?

If you miss the underlying concept of being able to take pieces of functionality and use them to create additional functionality; no book can help you.

I tried to buy it, but... (0)

Anonymous Coward | more than 7 years ago | (#18212928)

well I went to oreily and tried to buy it, but no ebook version - so I tried another online shop that sold it in e-book version got all the way to checkout and their payment processor site was down. So now I am going to open emule and get it there, can't say i didn't try to pay the $10...

another "idea" (3, Insightful)

Anonymous Coward | more than 7 years ago | (#18213306)

Hence the growing popularity of programming "cookbooks," which are filled with "recipes," each comprising a concise statement of a focused problem, followed by a solution, with plenty of sample code to show how to implement it.

Of course, another option is to learn the "fundamentals" and "theory" of data management, so that you can "understand" data management at a more "abstract" and "fundamental" level, instead of relying on "cookbooks" and "recipes" that you can copy mindlessly. Then you can save "money" on "cookbooks" when the "next big thing" comes around, because you already "know" that it's the "same thing" with "different syntax".

Imagine a "heart surgery cookbook" for newbies? A "bridge designing cookbook"? An "accounting cookbook"? What do you think of surgeons, engineers, or accountants who carry those around, tucked under their arm?

On the other hand, it's quite "profitable" for "consultants" like "me" to come in a clean up the "garbage" that the "cookbook"-using "idiots" "write".

(I guess all the "quotes" are a nod to MySQL's ability to accept strings in place of other types? Is there a recipe to fix that?)

Re:another "idea" (2, Informative)

Shados (741919) | more than 7 years ago | (#18213590)

Recipes have a lot in common with design patterns, or best practices. That is, they are far more "real world" than the fundamentals. And while the typical computer science major will have trouble understanding that (I don't mean you, btw), yes, the technology you use matters.

For example, whats efficient in MySQL, isn't whats efficient in SQL Server, and vice versa. That makes for extreme differences in whats the best architecture and best practices between environments. It tends to be extremely visible in "similar, but not" environments, like, again, MySQL vs SQL Server, C# vs Java, VB.NET vs VB6, and so on. People that think the fundamentals are all there is, end up applying something that works (amazingly well) in one world, in another, and then all hells break loose. I'm currently having to deal a lot with Java and C++ programmers (all extremely senior in their field), that are trying to apply their patterns and practices in .NET, and its a total disaster. The same would apply if the other way around happened, I am sure.

Simply put, we don't (frequently) code B-Trees, linked lists and matrix transformations anymore (certain fields do, but sure as hell not the fields that would have someone even spend a moment learning fundamentals, so we can ignore those). Anything that actually "matters", caching, distributed applications, clustering, Business Intelligences, reversal of dependency, optimisation, you name it, is night and day from one environment to another. Thats why these "recipes" exist.

Now, I'm not sure if a recipe book is a good solution, since as you said, people will just copy and paste them, but the concepts (often environment specific!) shown in there are important, and WILL have to be relearnt when doing anything significant using the "next buzz-word compliant thing".

Re:another "idea" (1)

Watson Ladd (955755) | more than 7 years ago | (#18214440)

Not so. Let's look at your list one by one:
  1. Caching: If we are caching function values, then it's very similar across languages.
  2. Distributed Applications: Message-passing is the same in C or Erlang. The differences are ones of flexibility vs performance. But if you have a design in one, it probably will translate to the other without much difficulty.
  3. Clustering: See above
  4. I have no idea what Business Intelligences are.
  5. Reversal of Dependency: This is a design pattern that is defined in terms of low level constructs. It's cross-platform.
  6. Optimization: Most optimization is algorithmic. This is inherently cross-platform
Maybe I'm missing something big, but all the recipes you listed seem to translate easily across platform.

Re:another "idea" (2, Interesting)

Shados (741919) | more than 7 years ago | (#18214618)

Caching: different if we're dealing with a web application. If you're using a cluster, you have to share cache dependency to keep it in sync, and depending on clustering technology/tools, its different.

Distributed applications: RMI in Java, C++, or .NET are different. Or are we using web services? Unless you're coding from scratch, different across environments. Do we make the WSDL manually, does the framework generate it on the fly? God forbid you're using Windows Communication Foundation, or Corba? Best practices and architecture are totally different.

Clustering: In ASP.NET you'll need to switch over to a state server else sessions won't work. Most mainstream RDBMS will link almost transparently, but with those that don't, you'll need to get creative. This one is almost purely dependant on technology, and different environments will have different ways of dealing with the mass servers.

BI: Data mining and such. SQL Server has a bunch of proprietary mechanics and ways of dealing with cubes and data models, and how to train them... Oracle of other ways, other third party tools have theirs. Or you can code from scratch. Depends on your needs, 100% different either way: the theorical concept is the same, the implementation, totally different.

Reversal of Dependency: Different languages, different ways of loading an object from a configuration. .NET's objects are all introspectable by definition. Javas are not, so you need to do things differently. .NET's best practice would build around the Provider pattern, which can be done by inheriting objects made for that purpose entirely. In Java (last time I checked, might have changed), you have to go by the design pattern from scratch. Or use Spring, for example.

Optimisation: totally different accross environments. For real RDBMS, you have to avoid cursors at all cost. For transactional engines with a relational API, you might need to use cursors like hell. .NET has constructs to ease async calls built in web service proxies and database calls without ever having to make a thread instance, in Java, its handled differently.

Another example: the Observer Pattern. In Java its a standard design pattern, in .NET you use delegates. What about threads? I used to work on socket servers, handling concurrent connection. I had to do the same darn thing in .NET just today, and realised the best practices for locking and synchronising threads were completly different. Different constructs. Same logic, yes, but completly different ways of doing things cleanly.

And the list go on. Im comparing Java and .NET here because they're so close, yet all the best practices are different. If you compare PHP and .NET, its so freagin different, when you look at forums, you keep seeing PHP programmers begging to know how you can easily make a table by looping and outputting HTML, but its horrible practice. And it goes the other way around in reverse.

If we compared low level stuff, like string manipulation, pointer arithmetics, etc, yes, its the same across languages. But unless you're coding a driver, working on the Linux kernel, or coding in C, you're not going to do things that people have done 19274092174902 times over in the past. What you're more likely to do is make softwares that integrate one way or another with their environment. And thats never the same. It might LOOK the same. And thats the pitfall.

Seeing someone implement the Observer pattern in .NET makes me feel sick everytime...

Re:another "idea" (1)

Bastard of Subhumani (827601) | more than 7 years ago | (#18216366)

Recipes have a lot in common with design patterns
Do they? A design pattern is an abstract, theoretical, generic approach to a solution. A recipe is a concrete solution to a specifc problem.

I'm currently having to deal a lot with Java and C++ programmers (all extremely senior in their field), that are trying to apply their patterns and practices in .NET, and its a total disaster.
Sounds like they're cribbing code, not applying patterns.

Re:another "idea" (1)

Shados (741919) | more than 7 years ago | (#18218922)

[blockquote]Do they? A design pattern is an abstract, theoretical, generic approach to a solution. A recipe is a concrete solution to a specifc problem.[/blockquote]

Abstract, yeah. Generic, yes. Theoritical? Hell freagin no. Design patterns are practical way of solving -implementation- problems. That implementation will differ accross environments.

Best example in the book: The Observer pattern. In C++ or Java, you implement it "by the book". In .NET, you use a delagate.

Or some design patterns are solutions that were made for lack of better ways of solving a problem. The MVC pattern is one of em. In certain environments, its a de facto standard to decouple the presentation from the rest of the system. In other environments (that came later for the most part), its useless to achieve the same result.

Re:another "idea" (0)

Anonymous Coward | more than 7 years ago | (#18213672)

'Single quotes' are how you represent 'strings' in SQL. Of course MySQL is "different" unless you enable the TRY_TO_NOT_RANDOMLY_BREAK_SQL_SYNTAX option.

Re:another "idea" (1)

IdahoEv (195056) | more than 7 years ago | (#18214628)

I have a client who uses quotes at totally random places in her sentences in every email. I can never tell exactly what she is trying to say by that.

Typical: Evan, can you "update" the web pages with the information I've attached below?

What, do you want me to update it or not? Is this a joke?

Some people learn by example (2, Insightful)

turing_m (1030530) | more than 7 years ago | (#18214726)

Imagine a "checklist" for a pilot! What would you think of a pilot with a checklist tucked under his arm? I'd hope that my surgeon had a checklist too, that way I'd be far less likely to get an X-ray several years later revealing a surgical instrument left inside me.

Concerns over the (dubious) trustworthiness of MySeQueL to hold your precious data aside, a good recipe can prove invaluable for reasons besides making sure you're not forgetting anything.

I'm an engineer. At some stage, you have to understand the theory. However, I find that I learn best by osmosis. If I first learn how to do problems, then I have a context to place the theory and a motivation to learn it.

Do you build your skill as a writer by picking up Elements of Style, a dictionary and a book on grammar, or first addicting yourself to reading novels and then reading about theory? For most people it's the former. It's also how you learned spoken language as a child. The brain is in fact very well adapted to that mode of learning.

The problem is not with cookbooks but with people who have no desire at all to learn the theory, or who don't ask "What could I be potentially screwing up by taking this approach?".

Re:another "idea" (1)

Bluesman (104513) | more than 7 years ago | (#18215496)

Of course, another option is to learn the "fundamentals" and "theory" of data management, so that you can "understand" data management at a more "abstract" and "fundamental" level, instead of relying on "cookbooks" and "recipes" that you can copy mindlessly.

At which point you'd be horrified at the way MySQL "handles" data and how the query "optimizer" really deserves to have the quotes around it, so much so that you'll be begging to use a database that offers more than really fast SELECTS on a single table.

And my guess is that this is why this cookbook exists, to offer hackish solutions to problems that would be otherwise elegantly solved by features that MySQL is either missing or implements half-assed.

I apologize if I sound bitter, it's because I've been wrangling with MySQL for the past week, trying to get it run *slightly* complex queries faster than I could do them by writing the tables down on paper and doing them by hand. Long story short, the db screams now, but I had to implement in my application what should be handled by partial indices or views, which MyISAM (best you get on most web hosting) doesn't support. It's enough to piss of the Good Humor man.

MySQL does have its place, though, and that's if you have a data set with a single table (or few/no relationships between tables) and Berkeley DB doesn't offer flexible enough searches for your application.

Re:another "idea" (1)

gordo3000 (785698) | more than 7 years ago | (#18216626)

you know, I work in a field where SQL shouldn't be terribly needed(front office of a trading floor) but every now and then something goes down in the system and since our system guys are 12 hours removed from us, we find out when they are eating dinner or going to sleep. So we have actually been creating our own cookbook to query the database. every time some need arises, we basically file it away in a large spreadsheet that you can copy and paste into Query Analyzer. for us, the cookbook would be great. we aren't database guys. Its not our realm to program outside of VBA (though all of us have some skill outside of it).

So while I understand that if our systems guys are sitting there using a cookbook to handle querying a database that it is there job to maintain is troublesome, I find these books extremely helpful because I shouldn't be spending my time learning all the fundamentals of database management when I should be studying the mathematics behind the current pricing models we use.

yeah, its mindless. but sometimes that's all you need if you are trying to hack together some 20 line query to do some very basic things.

May as well have a broiled dog shit cookbook (0)

Anonymous Coward | more than 7 years ago | (#18214014)

MySql Cookbook? Fuck. What a waste of time. GET OVER IT FANBOYS - IT SUCKS and IS NOT FREE.

Postgres is better (the glaringly obvious replacement).
Firebird is better
MSSQL Express is better
Oracle Express is better
catshit pancakes are better.

Why the almighty "they" let you goddamn noobs continue working with that fucking POS glorified datastore is beyond common sense and well past insanity.

Recipe #1, polishing your "database" (0)

Anonymous Coward | more than 7 years ago | (#18214474)

1. Place "database" in dehumidifier.
2. Leave for 1 week.
3. "Database" should be dry. Check.
4. Using 1500 grit sandpaper, gently sand, taking care that your "database" does not suffer an integrity failure, otherwise you will need to begin with a new "installation". NB: Do NOT use wet n' dry.
5. Repeat step 4 with 2000 grit sandpaper, then buff with lambswool.
6. Apply Mequire's Gold Class polish, then buff dry with a terry cloth.

I'll give it a 3/5 (2, Interesting)

Ikoma Andy (41693) | more than 7 years ago | (#18214282)

I love the Perl Cookbook, nearly the single most useful book I own. I recently started working on some Perl/MySQL stuff again about a month ago, so I bought this book. I have not found it as useful. Now, this may be because I'm not a MySQL power user, I poke at it about once a year, just infrequently enough that I have to relearn everything again-- but you'd think this would be exactly the book I need.

There's very little on subselects-- in fact, in trying to provide a page count, I can't find subselect in the index, even under select. The JOIN information is scattered through a few related recipes and is okay, but just okay. I had a pretty complicated (for me) SELECT statement I was trying to do, a LEFT JOIN with some WHERE information and a subselect with some other stuff...I don't recall the specifics, but the book was only moderately helpful, I wound up just trial and erroring my way through until it did what I wanted. There is some general management info, but no password recovery? Everytime I have to touch MySQL, step number one for me is typically password recovery, as I've forgotten everything since the last time.

It's a big book, and seems to cover a lot of ground (for example, about 70 pages of recipes relating to dates), so I'm sure there's some good in here. With the Perl Cookbook, I can't say that I've used the whole thing, but there are particular sections that I return to again and again (custom sorting on hash keys, etc...) The MySQL Cookbook just doesn't seem to be syncing up with my problems the way the Perl Cookbook does. I use more Perl than MySQL, though, so maybe it would do better if you knew MySQL in more depth than I do. It may be a problem with my limitations, but then again, I would have thought a Cookbook would be exactly the book to help.

first p0st (-1, Flamebait)

Anonymous Coward | more than 7 years ago | (#18214296)

you Fail4 It!! (-1, Flamebait)

Anonymous Coward | more than 7 years ago | (#18214420)

outreAch 4re [goat.cx]

FP cOCK (-1, Redundant)

Anonymous Coward | more than 7 years ago | (#18214794)

would 7ake About 2 share. FreeBSD is

My God - A Book!!! (0)

Anonymous Coward | more than 7 years ago | (#18216776)

How is this newsworthy?
Check for New Comments
Slashdot Login

Need an Account?

Forgot your password?