Untitled

mail@pastecode.io avatar
unknown
sql
2 months ago
1.2 kB
2
Indexable
Never

CREATE TABLE Item
(
    Id UNIQUEIDENTIFIER PRIMARY KEY,
    [Name] NVARCHAR(MAX) NOT NULL,
    Description NVARCHAR(MAX) NOT NULL,
    PhotoUrl NVARCHAR(MAX) NOT NULL
);


CREATE TABLE Product
(
    Id UNIQUEIDENTIFIER PRIMARY KEY,
    [Name] NVARCHAR(MAX) NOT NULL,
    Price FLOAT NOT NULL
);



CREATE TABLE Color
(
    Id UNIQUEIDENTIFIER PRIMARY KEY,
    [Name] NVARCHAR(MAX) NOT NULL,
    [Code] NVARCHAR(20) NOT NULL,
    ItemId UNIQUEIDENTIFIER,
    ProductId UNIQUEIDENTIFIER,
    FOREIGN KEY (ItemId) REFERENCES Item(Id),
    FOREIGN KEY (ProductId) REFERENCES Product(Id)
);


CREATE TABLE Feedback
(
    Id UNIQUEIDENTIFIER PRIMARY KEY,
    Rating FLOAT NOT NULL,
    [Comment] NVARCHAR(MAX) NOT NULL,
    ItemId UNIQUEIDENTIFIER,
    ProductId UNIQUEIDENTIFIER,
    FOREIGN KEY (ItemId) REFERENCES Item(Id),
    FOREIGN KEY (ProductId) REFERENCES Product(Id)
);


CREATE TABLE [User]
(
    Id UNIQUEIDENTIFIER PRIMARY KEY,
    [Name] NVARCHAR(MAX) NOT NULL,
    Email NVARCHAR(MAX) NOT NULL,
    FeedbackId UNIQUEIDENTIFIER,
    FOREIGN KEY (FeedbackId) REFERENCES Feedback(Id)
);



CREATE TABLE Vendor
(
    Id UNIQUEIDENTIFIER PRIMARY KEY,
    [Name] NVARCHAR(MAX) NOT NULL,
    Enlisted BIT NOT NULL
);
Leave a Comment