问题
So say you already know how to do basic things with databases e.g. create them...:) and you understand basic concepts like views and joins..and basic SQL syntax....but you just don't feel comfortable that your solutions follow the "best practices" or are even "correct".
Where could you read up something relatively rigorous but straight to the point for someone trying to build a database driven website? something that would say when/why joins are bad, when to cache, what kinds of queries are expensive, maybe have some exercises and hints/ solutions? something with a little bit of math as well?
Something like an e-book or some lecture notes may be the most appropriate but any suggestions are welcome!
回答1:
- Work with people more experienced than you
- Make lots of mistakes... and make sure you learn from them!
- Start reading books on relational databases
- Learn the internal details of your specific dbms (the optimizer in particular)
The only real shortcut is #1.
Once you begin to feel confident in modelling, start utilizing the knowledge of the internals of your specific dbms. It can be a big payoff to tilt minor design choices in ways that are benificial for your particular dbms. (Fixed length records and clustering comes to mind in MySQL).
You also need a thick and boring book on the fundamentals of relational database design to impress your friends and fellow coworkers. The best book for this purpose I've found is C.J Date's An Introduction to Database Systems. Apart from being just as thick and boring as its author, it unfortunately has some of the best material on the topic of normalization and relational theory.
I second @Cade Roux advice about Celko's books, and especially recommend "SQL for Smarties" or "Data and Databases".
回答2:
A Developer's Guide to Data Modeling for SQL Server: Covering SQL Server 2005 and 2008
Now I know this isn't directly for MySQL but the book was very easy to follow and very informative in just overall design concerns. I would also assume there is some basic transference of the information from one server to another server. (You can get this as an eBook as well as a normal book)
Hope this helps.
回答3:
The problem is that nothing is cut and dried in databases (as if it is anywhere else).
It all depends on context.
And most examples are usually toy problems, which may or may not really fit your actual scenario.
Everything depends.
JOINs in queries will very rarely perform as poorly as executing extra trips to the database. After all, if you look at an execution plan, it will tell you what the most efficient way the database found to retrieve the rows based on the keys/indexes/etc. Unless your SQL was wrong or your database design particularly hairy and non-normalized (allowing multiple paths), it's unlikely that the optimizer will make a poorer decision than your application code and it's going to do it all in one place.
For understanding database design, I would point you to Celko's books.
回答4:
A book used by lots of universities is "Database System Concepts" by "Silberschatz":
http://www.amazon.com/Database-System-Concepts-Abraham-Silberschatz/dp/0073523321/
回答5:
I can't believe nobody mentioned The manga guide to databases
来源:https://stackoverflow.com/questions/5598874/what-are-some-good-references-for-learning-relational-database-design-quickly