domingo, septiembre 05, 2010

SQL antipatterns

Termine de leer otro libro, SQL Antipatterns, veamos. Ultimamente han proliferado los ORM, como hibernate, y con el surgimiento de ruby on rails, el patrón de ActiveRecord; ¿qué es lo que esto ha ocacionado?, pues un completo desperdicio de los motores de base de datos, y un aumento de antipatrones en el diseño de la DB. Sin mas con este libro te sorprenderás de lo fácil que es hacer queries y hacerlos bien, nunca he entendido como es que se prefiere la complejidad de hsql, el no entender que SQL es un lenguaje declarativo es de los peores errores de un programador, a SQL le dices que es lo que quieres, no las instrucciones de como hacer lo que quieres.

Es un libro ligero, de una buena lectura, que si tienes algo de experiencia en diferentes proyectos, te darás cuenta que tan recuerrente son estas malas prácticas y cuando leas la solución verás que era muy fácil no caer en ellas.

Aqui algunas anotaciones de mi kindle:

==========

SQL Antipatterns

- Highlight Loc. 1699-1704 | Added on Sunday, August 08, 2010, 04:35 PM

SELECT * FROM Comments AS c LEFT OUTER JOIN (BugsComments JOIN Bugs AS b USING (issue_id)) USING (comment_id) LEFT OUTER JOIN (FeaturesComments JOIN FeatureRequests AS f USING (issue_id)) USING (comment_id) WHERE c.comment_id = 9876;

==========

SQL Antipatterns

- Highlight Loc. 2233-36 | Added on Sunday, August 08, 2010, 07:16 PM

IEEE 754 represents floating-point numbers in a base-2 format. The values that require infinite precision in binary are different values from those that behave this way in decimal. Some values that only need finite precision in decimal, for instance 59.95, require infinite precision to be represented exactly in binary. The FLOAT data type can't do this, so it uses the closest value in base-2 it can store, which is equal to 59.950000762939 in base-10.


==========

SQL Antipatterns

- Highlight Loc. 4777-78 | Added on Monday, August 30, 2010, 07:48 AM


Mitch Ratcliffe said, "A computer lets you make more mistakes faster than any other human invention in human history…with the possible exception of handguns and tequila."

==========

SQL Antipatterns

- Highlight Loc. 4822-26 | Added on Monday, August 30, 2010, 07:55 AM

But do the math: if you generate unique primary key values as you insert 1,000 rows per second, 24 hours per day, you can continue for 136 years before you use all values in an unsigned 32-bit integer. If that doesn't meet your needs, then use a 64-bit integer. Now you can use 1 million integers per second continuously for 584,542 years. It's very unlikely that you will run out of integers!

==========

SQL Antipatterns

- Highlight Loc. 5037-40 | Added on Monday, August 30, 2010, 10:56 PM

Even among developers who accept best practices when developing application code, there's a tendency to think of database code as exempt from these practices. I call this antipattern Diplomatic Immunity because it assumes that the rules of application development don't apply to database development.

==========

SQL Antipatterns

- Highlight Loc. 5537-38 | Added on Wednesday, September 01, 2010, 07:14 AM

Young man, in mathematics you don't understand things. You just get used to them. John von Neumann

==========

SQL Antipatterns

- Highlight Loc. 5549-51 | Added on Wednesday, September 01, 2010, 07:16 AM

This term relational doesn't refer to relationships between tables. It refers to the table itself, or rather, the relationship between columns within a table. In a way, it refers to both.


Publicar un comentario