Mistake zero, not mentioned by Nielsen but the most important and common
in amateur pages: unreadable text, e.g. dark text on a dark background,
or light on light. The Discus software we're using for 134A has this
mistake: the button "Post this message" has black text on a dark blue background
under Netscape 4.7 on my Linux box. (It looks fine under Mozilla
and IE on Windows so this is another example of how testing necessary on
multiple browsers and platforms.)
The db server takes care of maintaining the tables on disk, of allowing multiple db clients to read and write to them without data corruption, and of keeping copies cached in memory to increase read/write speed.
All database operations are specified using a language of commands called SQL. For example:
create table temp (The syntax of the SQL language is inspired by Cobol, a 1960s business-oriented language. Upper/lower case is not significant.
k integer unsigned not null,
s double not null,
d datetime not null,
quantile double not null )
The strange range for TIMESTAMP comes from a Unix-specific representation.
Unlike in most programming languages, the basic types also have modifiers available. These include:
The answer from a query is called a "result set." Conceptually, a result set is the same as a new table, except that result sets are not stored persistently in the database.
Result sets can be ordered:
select author, date
from messages
where date > '2000-11-11'
order by date
Each line that adds detail to what should be selected is called a "clause."
The example above has from, where, and order by
clauses. By default order is increasing.
delete from messages where date < '2000-11-11';Syntax note: curdate() is a builtin SQL function, not a PHP function. Semantics note: the where clause is optional in delete and update commands. If you leave it out, every record will be affected. This is almost never what you want.
update messages set author = 'John Smith' where author = 'Smith';
insert messages (author, date) values('Brown',curdate());
Usually your PHP script will build up an SQL command by concatenating various substrings, and then send the command to be executed by the MySQL server. For example:
$cmd = "insert messages (author, date) values('Brown'," . today() . ")";In the PHP code above, today() is a PHP function.
$result = mysql_query($cmd, $link);
What happens when we create a new tuple and only provide values for some of its fields? Then the database server fills in default values for the remaining fields. The most common default value is NULL.
What happens when an insert command fails to specify a value for a field
that is supposed to be NOT NULL? I couldn't find the answer
in our MySQL book!
create table messages (Now every record should be inserted with a NULL value for the field named id. The server will then automatically assign a value to this field that is one larger than the largest value ever assigned previously to a record for this table.
...
id integer unsigned not null auto_increment primary key
... )
select count(*) from messages;Note that distinct is a keyword, written without parentheses, but dayofweek() is a builtin function. Other builtin group-based functions include min, max, sum, and avg.select count(*) from messages where author = 'Smith';
select max(date) from messages where author = 'Smith';
select distinct author from messages order by author;
select count(distinct author) from messages;