Learning PHP and MySQL

Chapter 7 Code

Friday, August 18, 2006

Example 07-01 Creating the books and authors tables

CREATE TABLE books title_id INT NOT NULL AUTO_INCREMENT
                     
title VARCHAR (150),
                     
pages INT,
                     
PRIMARY KEY (title_id)); 
CREATE TABLE authors author_id INT NOT NULL AUTO_INCREMENT
                       
title_id INT NOT NULL,
                       
author VARCHAR (125), 
                       
PRIMARY KEY (author_id));

Posted by krautgrrl on 08/18 at 10:40 AM
Chapter 7 Code • (0) Comments • (27) TrackbacksPermalink

Example 07-02 The SQL to create and populate a purchases table that links user_ids and title_ids

This code is for:
The SQL to create and populate a purchases table that links user_ids and title_ids to a purchase_id

CREATE TABLE `purchases` ( purchase_id int(11NOT NULL auto_increment
                           
user_id varchar(10NOT NULL,
                           
title_id int(11NOT NULL,
                           
purchased timestamp NOT NULL default CURRENT_TIMESTAMP
                           
PRIMARY KEY  (purchase_id));
INSERT INTO `purchasesVALUES (1'mdavis'2'2005-11-26 17:04:29');
INSERT INTO `purchasesVALUES (2'mdavis'1'2005-11-26 17:05:58');

Posted by krautgrrl on 08/18 at 10:41 AM
Chapter 7 Code • (5) Comments • (391) TrackbacksPermalink

Statistics

This page has been viewed 271369 times
Page rendered in 0.1370 seconds
Total Entries: 224
Total Comments: 16
Total Trackbacks: 307338
Most Recent Entry: 09/27/2006 12:39 pm
Most Recent Comment on: 10/26/2007 10:00 am
Total Members: 2
Total Logged in members: 0
Total guests: 9
Total anonymous users: 0
Most Recent Visitor on: 07/30/2010 05:21 am
The most visitors ever was 1103 on 11/20/2007 12:50 pm

Referrers

Powered by ExpressionEngine