0% found this document useful (0 votes)
23 views1 page

Es 2 - Un Carrello Di Dati

Uploaded by

b59y9ggb9h
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views1 page

Es 2 - Un Carrello Di Dati

Uploaded by

b59y9ggb9h
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

CREATE DATABASE Negozio;

USE Negozio;

CREATE TABLE Categories (


Id INT PRIMARY KEY,
Name VARCHAR(100) NOT NULL
);

CREATE TABLE Products (


Id INT PRIMARY KEY,
Name VARCHAR(100) NOT NULL,
CategoryId INT,
Price DECIMAL(10, 2) NOT NULL,
FOREIGN KEY (CategoryId) REFERENCES Categories(Id)
);

CREATE TABLE Clients (


Id INT PRIMARY KEY,
FirstName VARCHAR(100) NOT NULL,
LastName VARCHAR(100) NOT NULL
);

CREATE TABLE Orders (


Id INT PRIMARY KEY,
ClientId INT,
Year YEAR NOT NULL,
FOREIGN KEY (ClientId) REFERENCES Clients(Id)
);

CREATE TABLE OrderItems (


OrderId INT,
ProductId INT,
Quantity INT NOT NULL,
Price DECIMAL(10, 2) NOT NULL,
PRIMARY KEY (OrderId, ProductId),
FOREIGN KEY (OrderId) REFERENCES Orders(Id),
FOREIGN KEY (ProductId) REFERENCES Products(Id)
);

You might also like