Let’s look at the relationship between each tableAfter analysis, first build database, then build table, build table order is very important, need toBy a foreign key(If the public key is the primary key in one relationship, the public key is called the foreign key of the other relationship.) The table pointing to is built first, followed by other tables.

The order is: User table category Table Property Table Product Table Property Value Table Product Picture Table Evaluation Table Order Table Order item table

CREATE DATABASE tianmao_springboot DEFAULT CHARACTER SET utf8;
use tianmao_springboot;
CREATE TABLE user (
        id int(11) not null atuo_indcremnt,
        name varchar(255) not null,
        password varchar(255) no null,
        salt varchar(255) default null,
        primary key(id)
}endgine=innobo default charset=utf8;

CREATE TABLE property (
  id int(11) NOT NULL AUTO_INCREMENT,
  cid int(11) DEFAULT NULL,
  name varchar(255) DEFAULT NULL,
  primary KEY (id),
  constraint fk_property_category FOREIGN KEY (cid) REFERENCES category (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Copy the code

Fk_property_category FOREIGN KEY (CID) REFERENCES Category (ID) is used to link two tables together. The linked FOREIGN KEY field is ID

ENGINE=InnoDB Uses the BAIInnodb ENGINE

DEFAULT CHARSET= UTF8 The DEFAULT password of the database is UTF-8

Other database code similar to the above, please type to read