2010-05-08 98 views
-1

我工作的web應用生成SQL的網站

如何創建SQL以下

數據庫信息

User information 
Username - String 
Password - String 
Admin or Client - boolean 
Last login – Date/Time 

LogItem 
typeLogItem – String (Page name?) 
hitCount – int 

View 
PageURL 
UserID 

Transaction 
User – String 
DateTimeStamp 
SKU – int 
Purchase-boolean 
TransactionID-int 

Inventory information 

Sku number - int 
Item description - String 
Price to customer - double 
Count - in 
+0

如果你用文字說明你要做什麼樣的數據庫模式會更好;發佈該代碼示例並不能真正顯示您正在嘗試構建的內容。 – ABach 2010-05-08 19:28:58

回答

1
CREATE TABLE `user` (
    `id` INT auto_increment PRIMARY KEY, 
    `name` VARCHAR(255), 
    `password` VARCHAR(255), 
    `admin` BIT, 
    `last_login` DATETIME 
); 
CREATE TABLE `log_item` (
    `id` INT auto_increment PRIMARY KEY, 
    `type` VARCHAR(255), 
    `hitcount` INT 
); 
CREATE TABLE `view` (
    `id` INT auto_increment PRIMARY KEY, 
    `page_url` VARCHAR(255), 
    `user_id` INT 
); 
CREATE TABLE `transaction` (
    `id` INT auto_increment PRIMARY KEY, 
    `user_id` INT, 
    `date` DATETIME, 
    `sku` INT, 
    `purchase` BIT 
); 
CREATE TABLE `inventory` (
    `id` INT auto_increment PRIMARY KEY, 
    `sku` INT, 
    `description` TEXT, 
    `price` FLOAT, 
    `count` INT 
); 

應該是幾乎你想要什麼?如果它們不夠大,你可能需要調整一些varchar大小。