CSC220 Database Management Systems

From dftwiki3
Revision as of 07:08, 6 October 2010 by Thiebaut (talk | contribs) (Created page with '--~~~~ ---- __TOC__ =Example= * Users, purchasing items from a store. * 3 tables: users, orders, items CREATE TABLE `users` ( `userId` INT(1) NOT NULL AUTO_INCREMENT, `…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

--D. Thiebaut 12:08, 6 October 2010 (UTC)


Contents


Example

  • Users, purchasing items from a store.
  • 3 tables: users, orders, items
CREATE TABLE `users` (
 `userId` INT(1) NOT NULL AUTO_INCREMENT,
 `userName` VARCHAR(100) DEFAULT NULL,
 PRIMARY KEY  (`userId`)
) ENGINE=MYISAM DEFAULT CHARSET=utf8;


CREATE TABLE `orders` (
 `orderId` INT(1) NOT NULL AUTO_INCREMENT,
 `userId` INT(1) DEFAULT NULL,
 `itemId` INT(1) DEFAULT NULL,
 PRIMARY KEY  (`orderId`)
) ENGINE=MYISAM DEFAULT CHARSET=utf8;


CREATE TABLE `items` (
 `itemId` INT(1) NOT NULL AUTO_INCREMENT,
 `itemName` VARCHAR(100) DEFAULT NULL,
 `price` FLOAT DEFAULT NULL,
 PRIMARY KEY  (`itemId`)
) ENGINE=MYISAM DEFAULT CHARSET=utf8;