Friday, 24 August 2007

PHP Basics (Section 1) - Database

I'd like to blog my understanding of PHP based on my 10+ years experience in developing scalable web based applications. There will be 14 sections in total, including: database, functions, strings, security, design pattern, javascript and more... :-) Here is the first section --- DATABASE

  1. Database cannot be tested by using specific code.
  2. While PHP is loosely types, databases are not. Therefore, detailed Information about the data being stored is required for efficient storage and retrieval, common data-types include: int(signed integer number, 32bits), char(fixed length character string), varchar(variable length character string), float(signed floating point number, 64bits)
  3. Most modern database systems fall into the relational category, the basis of which is the relationship between various tables
  4. Relationships link records based on some common data, relationships can be one to one, one to many, many to many
  5. DB systems can be configured to enforce those relationships to maintain referential integrity
  6. DB are smart and fast, but the DB designer has foreknowledge of how the DB will be used
  7. With this knowledge the designer can create an index on appropriate columns
  8. This index instructs the DBMS to store additional information about the data in that column, to make locating data within it as fast as possible
  9. Transactions allow you to merge multiple queries into one atomic operation, either they ALL execute successfully, or none do. (BEGIN TRANSACTION #name; ...queries here, COMMIT;) - Transactions are only available on InnoDB. :-)
So if you have a good idea which you think I need to improve (i.e. depth, examples, etc) , let me know and I will see what I can do.

No comments: