Nhập câu lệnh SQL (MySQL)
-- Create the Category table CREATE TABLE IF NOT EXISTS Category ( CategoryID INT PRIMARY KEY AUTO_INCREMENT, CategoryName VARCHAR(255) NOT NULL ); -- Create the Publisher table CREATE TABLE IF NOT EXISTS Publisher ( PublisherID INT PRIMARY KEY AUTO_INCREMENT, PublisherName VARCHAR(255) NOT NULL ); -- Create the Book table CREATE TABLE IF NOT EXISTS Book ( BookID INT PRIMARY KEY AUTO_INCREMENT, BookName VARCHAR(255) NOT NULL, Author VARCHAR(255), PublicationYear INT, CategoryID INT, PublisherID INT, Quantity INT NOT NULL DEFAULT 0, Price DECIMAL(10, 2) NOT NULL DEFAULT 0, DiscountPrice DECIMAL(10, 2) NOT NULL DEFAULT 0, FOREIGN KEY (CategoryID) REFERENCES Category(CategoryID), FOREIGN KEY (PublisherID) REFERENCES Publisher(PublisherID) );
Chuyển đổi từ SQL
[ { "class_name": "Category", "fields": [ { "name": "categoryid", "type": "int", "auto_increment": true, "is_primary": true, "constraints": [] }, { "name": "categoryname", "type": "String", "auto_increment": false, "is_primary": false, "constraints": [ "@NotNull" ] } ] }, { "class_name": "Product", "fields": [ { "name": "productid", "type": "int", "auto_increment": true, "is_primary": true, "constraints": [] }, { "name": "productname", "type": "String", "auto_increment": false, "is_primary": false, "constraints": [ "@NotNull" ] }, { "name": "price", "type": "double", "auto_increment": false, "is_primary": false, "constraints": [ "@NotNull", "@Check(price >= 0)" ] }, { "name": "date", "type": "Date", "auto_increment": false, "is_primary": false, "constraints": [ "@NotNull" ] }, { "name": "stock_quantity", "type": "int", "auto_increment": false, "is_primary": false, "constraints": [ "@NotNull" ] }, { "name": "image", "type": "String", "auto_increment": false, "is_primary": false, "constraints": [] }, { "name": "categoryid", "type": "int", "auto_increment": false, "is_primary": false, "constraints": [] } ] } ]
Temp Variable
Thêm dữ liệu
Download Zip
Download Base
Download Full Source
Output