Learning java-Book sales system-Database structure

Source: Internet
Author: User
Tags datetime

/*


MySQL Data Transfer


Source host:localhost


Source Database:book


Target host:localhost


Target Database:book


date:2008-7-25 13:55:48


*/


SET foreign_key_checks=0;


-- ----------------------------


--Table structure for T_book


-- ----------------------------


CREATE TABLE ' T_book ' (


' id ' int (one) not NULL auto_increment COMMENT ' serial number ',


' name ' varchar (MB) Collate utf8_unicode_ci not NULL COMMENT ' title ',


' Price ' decimal (10,2) is not NULL COMMENT ' prices ',


' quantity ' int (one) not NULL COMMENT ' quantity ',


PRIMARY KEY (' id '),


UNIQUE KEY ' name ' (' name ')


) Engine=innodb auto_increment=5 DEFAULT Charset=utf8 collate=utf8_unicode_ci;


-- ----------------------------


--Table structure for t_bookstockhistory


-- ----------------------------


CREATE TABLE ' t_bookstockhistory ' (


' id ' int (one) not NULL auto_increment COMMENT ' serial number ',


' bookid ' int (one) not NULL COMMENT ' book Number ',


' quantity ' int (one) not NULL COMMENT ' quantity ',


' quantityoutstanding ' int (one) not NULL COMMENT ' quantity balance ',


' Price ' decimal (10,2) is not NULL COMMENT ' prices ',


' datetime ' timestamp not NULL default current_timestamp on update current_timestamp COMMENT ' time ',


' note ' varchar (255) Collate utf8_unicode_ci default NULL COMMENT ' remarks ',


PRIMARY KEY (' id '),


KEY ' BookID ' (' BookID '),


CONSTRAINT ' t_bookstockhistory_ibfk_1 ' FOREIGN KEY (' BookID ') REFERENCES ' T_book ' (' id ')


) Engine=innodb auto_increment=5 DEFAULT Charset=utf8 collate=utf8_unicode_ci;


-- ----------------------------


--Table structure for T_order


-- ----------------------------


CREATE TABLE ' T_order ' (


' id ' int (one) not NULL auto_increment COMMENT ' serial number ',


' UserId ' int (one) not NULL COMMENT ' member Number ',


' Amount ' decimal (10,0) not NULL COMMENT ' total amount ',


' Datetime ' timestamp not NULL default current_timestamp on update current_timestamp COMMENT ' time ',


' note ' varchar collate utf8_unicode_ci default NULL COMMENT ' remarks ',


PRIMARY KEY (' id '),


KEY ' UserId ' (' UserId '),


CONSTRAINT ' t_order_ibfk_1 ' FOREIGN KEY (' UserId ') REFERENCES ' t_user ' (' Id ')


) Engine=innodb auto_increment=13 DEFAULT Charset=utf8 collate=utf8_unicode_ci;


-- ----------------------------


--Table structure for T_orderbook


-- ----------------------------


CREATE TABLE ' T_orderbook ' (


' Id ' int (one) not NULL auto_increment COMMENT ' flow number ',


' OrderId ' int (one) not NULL COMMENT ' order number ',


' bookid ' int (one) not NULL COMMENT ' book Number ',


' Quantity ' int (one) not NULL COMMENT ' quantity ',


PRIMARY KEY (' Id '),


KEY ' OrderId ' (' OrderId '),


KEY ' BookID ' (' BookID '),


CONSTRAINT ' t_orderbook_ibfk_1 ' FOREIGN KEY (' OrderId ') REFERENCES ' T_order ' (' id '),


CONSTRAINT ' t_orderbook_ibfk_2 ' FOREIGN KEY (' BookID ') REFERENCES ' T_book ' (' id ')


) Engine=innodb auto_increment=15 DEFAULT Charset=utf8 collate=utf8_unicode_ci;


-- ----------------------------


--Table structure for T_user


-- ----------------------------


CREATE TABLE ' T_user ' (


' Id ' int (one) not NULL auto_increment COMMENT ' serial number ',


' username ' varchar collate utf8_unicode_ci not NULL COMMENT ' username ',


' Password ' varchar collate utf8_unicode_ci not NULL COMMENT ' password ',


PRIMARY KEY (' Id '),


UNIQUE KEY ' username ' (' username ')


) Engine=innodb auto_increment=4 DEFAULT Charset=utf8 collate=utf8_unicode_ci;


-- ----------------------------


--Records


-- ----------------------------


INSERT into ' T_book ' VALUES (' 1 ', ' Java base 12 ', ' 25.01 ', ' 0 ');


INSERT into ' T_book ' VALUES (' 2 ', ' Java Advanced programming ', ' 89.23 ', ' 2 ');


INSERT into ' T_book ' VALUES (' 3 ', ' with the old Zhu Zi learning java ', ' 50.45 ', ' 3 ');


INSERT into ' T_book ' VALUES (' 4 ', ' Java Encyclopedia ', ' 111.00 ', ' 4 ');


INSERT into ' t_bookstockhistory ' VALUES (' 1 ', ' 3 ', ' 1 ', ' 1 ', ' 50.45 ', ' 2008-07-25 12:27:21 ', null);


INSERT into ' t_bookstockhistory ' VALUES (' 2 ', ' 2 ', ' 1 ', ' ', ', ' 89.23 ', ' 2008-07-25 12:29:18 ', null);


INSERT into ' t_bookstockhistory ' VALUES (' 3 ', ' 3 ', ' 1 ', ' 0 ', ' 50.45 ', ' 2008-07-25 12:29:18 ', null);


INSERT into ' t_bookstockhistory ' VALUES (' 4 ', ' 1 ', ' 1 ', ' 0 ', ' 25.01 ', ' 2008-07-25 13:32:24 ', ' member purchase ');


INSERT into ' t_order ' VALUES (' 7 ', ' 2 ', ' 2238 ', ' 2008-07-25 11:33:27 ', null);


INSERT into ' t_order ' VALUES (' 8 ', ' 2 ', ' 165 ', ' 2008-07-25 11:52:38 ', null);


INSERT into ' t_order ' VALUES (' 9 ', ' 2 ', ', ', ' 2008-07-25 11:58:51 ', null);


INSERT into ' t_order ' VALUES (' Ten ', ' 2 ', ', ', ' 2008-07-25 12:00:00 ', null);


INSERT into ' t_order ' VALUES (' One ', ' 2 ', ' 140 ', ' 2008-07-25 12:29:18 ', null);


INSERT into ' t_order ' VALUES (' ', ' 1 ', ', ', ' 2008-07-25 13:32:24 ', null);


INSERT into ' T_orderbook ' VALUES (' 5 ', ' 7 ', ' 1 ', ' 11 ');


INSERT into ' T_orderbook ' VALUES (' 6 ', ' 7 ', ' 2 ', ' 22 ');


INSERT into ' T_orderbook ' VALUES (' 7 ', ' 8 ', ' 1 ', ' 1 ');


INSERT into ' T_orderbook ' VALUES (' 8 ', ' 8 ', ' 2 ', ' 1 ');


INSERT into ' T_orderbook ' VALUES (' 9 ', ' 8 ', ' 3 ', ' 1 ');


INSERT into ' T_orderbook ' VALUES (' 10 ', ' 9 ', ' 1 ', ' 1 ');


INSERT into ' T_orderbook ' VALUES (' 11 ', ' 10 ', ' 1 ', ' 1 ');


INSERT into ' T_orderbook ' VALUES (' 12 ', ' 11 ', ' 2 ', ' 1 ');


INSERT into ' T_orderbook ' VALUES (' 13 ', ' 11 ', ' 3 ', ' 1 ');


INSERT into ' T_orderbook ' VALUES (' 14 ', ' 12 ', ' 1 ', ' 1 ');


INSERT into ' t_user ' VALUES (' 1 ', ' admin ', ' admin ');


INSERT into ' t_user ' VALUES (' 2 ', ' User ', ' user ');


INSERT into ' t_user ' VALUES (' 3 ', ' Test ', ' test ');

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.