Repository navigation
Expand file tree
/
Copy pathinit-script.sql
More file actions
54 lines (47 loc) · 2.18 KB
/
Copy pathinit-script.sql
File metadata and controls
54 lines (47 loc) · 2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
USE master;
GO
-- Create a new database
IF NOT EXISTS (SELECT name FROM sys.databases WHERE name = 'PriceNegotiationDB')
CREATE DATABASE PriceNegotiationDB;
GO
USE PriceNegotiationDB;
GO
-- Table for products
CREATE TABLE Products (
ProductID INT IDENTITY(1,1) PRIMARY KEY,
Name NVARCHAR(100) NOT NULL,
BasePrice DECIMAL(10, 2) NOT NULL
);
-- Table for users
CREATE TABLE Users (
UserID INT IDENTITY(1,1) PRIMARY KEY,
Name NVARCHAR(50) NOT NULL,
Email NVARCHAR(50) NOT NULL,
Role INT NOT NULL,
Password NVARCHAR(150) NOT NULL,
);
-- Table for negotiations
CREATE TABLE Negotiations (
NegotiationID INT IDENTITY(1,1) PRIMARY KEY,
ProductID INT,
ProposedPrice DECIMAL(10, 2) NOT NULL,
UserAttempts INT NOT NULL,
Status INT,
CreatorUserID INT,
CONSTRAINT FK_ProductID FOREIGN KEY (ProductID) REFERENCES Products(ProductID),
CONSTRAINT FK_CreatorUserID FOREIGN KEY (CreatorUserID) REFERENCES Users(UserID)
);
-- Inserting data into Products table
INSERT INTO Products (Name, BasePrice)
VALUES ('Smartphone', 499.99),
('Laptop', 899.50),
('Smartwatch', 199.00),
('Headphones', 149.99);
-- Inserting data into Users table
INSERT INTO Users (Name, Email, Role, Password)
VALUES ('testclient', 'testclient@example.com', 0, 'AQAAAAIAAYagAAAAELhqwE0SFAN44L8598yWkF0WcNbNTkuP4OmuKIYclIQmPczubiI5SQiBTD2NBwrJqQ=='), -- Password is 'toortoor'
('testadmin', 'testadmin@example.com', 1, 'AQAAAAIAAYagAAAAELhqwE0SFAN44L8598yWkF0WcNbNTkuP4OmuKIYclIQmPczubiI5SQiBTD2NBwrJqQ=='); -- Password is 'toortoor'
-- Inserting data into Negotiations table
INSERT INTO Negotiations (ProductID, ProposedPrice, UserAttempts, Status, CreatorUserID)
VALUES (1, 450.00, 2, 1, 1), -- Negotiation for Smartphone by testclient
(3, 180.00, 3, 0, 1); -- Negotiation for Smartwatch by testclient