为网站生成SQL

时间:2010-05-08 19:20:16

标签: sql mysql

我正在开发一个Web应用程序如何为以下

创建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

1 个答案:

答案 0 :(得分: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大小。