1.sql
①t_orderitem a foreign key
Bname: Convenient late book deletion
CREATE TABLE ' T_orderitem ' ( ' Orderitemid ' char (+) NOT null, ' quantity ' int (one) DEFAULT NULL, ' subtotal ' Decimal (8,2) default NULL, ' bid ' char (+) default null, ' bname ' varchar ($) default null, ' Currprice ' Decimal (8,2) default null, ' image_b ' varchar (+) default NULL, ' oid ' char (+) default NULL, PRIMARY KEY (' Orderitemid '), key ' Fk_t_orderitem_t_order ' (' oid '), CONSTRAINT ' Fk_t_orderitem_t_order ' FOREIGN KEY (' oid ') ) REFERENCES ' T_order ' (' oid ')) Engine=innodb DEFAULT charset=utf8;insert into ' T_orderitem ' (' Orderitemid ', ' Quantity ', ' Subtotal ', ' bid ', ' bname ', ' currprice ', ' image_b ', ' oid ') VALUES (' 01d2df3e5bb34e9f9d2477180c8d94d3 ', 1, ' 74.50 ', ' Ce01f15d435a4c51b0ad8202a318dca7 ', ' Java Programming Ideas (4th edition) ', ' 74.50 ', ' book_img/9317290-1_b.jpg ', ' C0841f4dfe7a43bfb183e4e82ae7914c ');
②t_order a foreign key
CREATE TABLE ' T_order ' ( ' oid ' char (+) NOT NULL, ' Ordertime ' char (+) DEFAULT NULL, ' Total ' decimal (10,2) DE FAULT null, ' status ' int (one) default NULL, ' address ' varchar (+) default NULL, ' uid ' char (+) default null , PRIMARY key (' oid '), key ' Fk_t_order_t_user ' (' uid '), CONSTRAINT ' Fk_t_order_t_user ' FOREIGN KEY (' uid ') REFERENCES ' T_user ' (' uid ')) Engine=innodb DEFAULT charset=utf8;insert into ' t_order ' (' oid ', ' ordertime ', ' total ', ' Status ', ' address ', ' uid ') VALUES (' 058f48da33694c6d8f5c2c13f3d26cea ', ' 2013-12-26 21:47:04 ', ' 95.30 ', 1, ' Ms. Li Jieyang, Guangdong province Jiedong County xxx xxx xxx ', ' 32DB3700D2564254982BC58B0E4D95BC ');
2.bean
①orderitem
public class OrderItem {private String orderitemid;//primary key private int quantity;//number private double subtotal;//Subtotal private book book;//the order to which bookprivate order order;//is associated
②order
public class Order {private string oid;//primary key private string ordertime;//order time private double total;//total private int status;// Single status: 1 unpaid, 2 paid but not shipped, 3 shipped unconfirmed receipt, 4 confirmed receipt of transaction succeeded, 5 canceled (only unpaid to cancel) private String address;//receipt address private User owner;// The owner of the order is private list<orderitem> orderitemlist;
Online Book Mall 6--order Module 1