The first table has been made with the help of  the command (CREAT TABLE)

CREATE TABLE Category(
idCategory int PRIMARY KEY,
CategoryName varchar(25) not null
);

In the second one we’ve used FOREIGN KEY to relate idCategory from (Product table) with idCategory in (Category  table). REFERENCES (ссылка) shows us where the point of access.

CREATE TABLE Product(
idProduct int PRIMARY KEY,
productName varchar(25) not null,
idCategory int,
price int,
FOREIGN KEY Product(idCategory) REFERENCES Category(idCategory)
);

The same operation is carried out on following table (Sale) only IdProduct is being gone to (Product table). Not null return True if there is found zero value

CREATE TABLE Sale(
idSale int PRIMARY KEY,
idProduct int,
idCustomer int,
Count int,
DateOfSale datetime not null,
FOREIGN KEY Sale(idProduct) REFERENCES Product(idProduct)
);

Was added a new row to (Sale table)

ALTER TABLE Sale

ADD Units varchar(15);

Data Type Changes

ALTER TABLE Sale 

CHANGE Count Count INT(11) NOT NULL;

No responses yet

Leave a Reply

Your email address will not be published. Required fields are marked *