Skip to content

Instantly share code, notes, and snippets.

@vrySantosh
Last active July 7, 2020 07:42
Show Gist options
  • Save vrySantosh/ccef382e15f174a0bf92ddf0c492d384 to your computer and use it in GitHub Desktop.
Save vrySantosh/ccef382e15f174a0bf92ddf0c492d384 to your computer and use it in GitHub Desktop.
--CREATE SCHEMA AllYouNeed;
--CREATE TABLE Customers(
-- CustomerID INT IDENTITY(1,1),
-- Name VARCHAR(50) NOT NULL,
-- Email VARCHAR(50) NOT NULL,
-- CONSTRAINT PK_Customer PRIMARY KEY (CustomerID)
-- );
--CREATE TABLE Products(
-- ProductID INT IDENTITY(1,1),
-- Name VARCHAR(50) NOT NULL,
-- Price DECIMAL(18,2) NOT NULL,
-- CONSTRAINT PK_Product PRIMARY KEY (ProductID)
-- );
CREATE TABLE Orders
(
OrderID INT IDENTITY(1,1),
ProductID INT NOT NULL,
CustomerID INT NOT NULL,
Status BIT NOT NULL,
CONSTRAINT PK_Orders PRIMARY KEY (OrderID),
CONSTRAINT FK_Orders_Products FOREIGN KEY (ProductID) REFERENCES Products(ProductID),
CONSTRAINT FK_Orders_Customers FOREIGN KEY (CustomerID) REFERENCES Customers(CustomerID)
);
//Insert Data
INSERT INTO Customers(Name, Email)
VALUES
('Santosh Guruju','santosh.guruju@macrokiosk.com'),
('Cris Carry','santosh.guruju@icloud.com');
--SELECT *
--FROM dbo.Customers;
--INSERT INTO Products(Name, Price)
--VALUES
-- ('6 Inch TV Cabinet',300.00),
-- ('L shape sofa', 3956.55);
SELECT * FROM Products;
INSERT INTO Orders(CustomerID, ProductID, Status)
VALUES
(1,1,1);
--SELECT * FROM Orders;
--DROP TABLE dbo.Orders;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment