1 year ago

#362248

test-img

user18258423

How to execute an entire table and create a database diagram

When I run my query, only one of my rows is displayed.

I also need to create a database diagram from these 3 tables Can someone please assist me on how to do that?

CREATE DATABASE Lab301;
CREATE TABLE Supplier(
    SupplierID NVARCHAR(50),
    Name NVARCHAR(50),
    Address NVARCHAR(50),
    PRIMARY KEY (SupplierID)
    )
INSERT INTO Supplier(SupplierID,Name,Address)
VALUES('S01','ABC Company','Penang');
INSERT INTO Supplier(SupplierID,Name,Address)
VALUES('S02','XYZ Company','Johor');
INSERT INTO Supplier(SupplierID,Name,Address)
VALUES('S03','HJK Company','Selagnor');
INSERT INTO Supplier(SupplierID,Name,Address)
VALUES('S04','PQR Company','Selagnor');
SELECT * FROM Supplier;

CREATE TABLE Product(
    ProductID NVARCHAR(50),
    Name NVARCHAR(50),
    PriceRM DECIMAL(10,2),
    QuantitInStock INTEGER,
    PRIMARY KEY (ProductID),
)
INSERT INTO Product(ProductID,Name,PriceRM,QuantitInStock)
VALUES('P01','Keyboard','103.55','60');
INSERT INTO Product(ProductID,Name,PriceRM,QuantitInStock)
VALUES('P02','Mouse','30.90','70');
INSERT INTO Product(ProductID,Name,PriceRM,QuantitInStock)
VALUES('P03','Monitor','200','80');
INSERT INTO Product(ProductID,Name,PriceRM,QuantitInStock)
VALUES('P04','Pendrive','40.30','50');
SELECT * FROM Product;

CREATE TABLE Supplies(
    SuppliesID NVARCHAR(50),
    SupplierID NVARCHAR(50),
    ProductID NVARCHAR(50),
    SuppliedDate DATE,
    QuantitySupplied INTEGER,
    PRIMARY KEY(SuppliesID),
    FOREIGN KEY(SupplierID) REFERENCES Supplier(SupplierID),
    FOREIGN KEY(ProductID) REFERENCES Product(ProductID),
)

INSERT INTO Supplies(SuppliesID,SupplierID,ProductID,SuppliedDate,QuantitySupplied)
VALUES('001','S01','P01','11/1/17','100');
INSERT INTO Supplies(SuppliesID,SupplierID,ProductID,SuppliedDate,QuantitySupplied)
VALUES('002','S01','P02','22/2/2017','200');
INSERT INTO Supplies(SuppliesID,SupplierID,ProductID,SuppliedDate,QuantitySupplied)
VALUES('003','S01','P03','NULL','300');
INSERT INTO Supplies(SuppliesID,SupplierID,ProductID,SuppliedDate,QuantitySupplied)
VALUES('004','S02','P03','30/4/2017','400');
SELECT * FROM Supplies;

sql

azure-sql-edge

0 Answers

Your Answer

Accepted video resources