How can i fix this error The INSERT statement conflicted with the FOREIGN KEY constraint "FK__products__Suppli__4D94879B" . CREATE DATABASE company; 2. USE company; zad 1.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

How can i fix this error The INSERT statement conflicted with the FOREIGN KEY constraint "FK__products__Suppli__4D94879B"

. CREATE DATABASE company;
2. USE company;
zad 1.
CREATE TABLE employees (
id int identity not null ,
EmpFirstName nvarchar(255),
EmplastName nvarchar(255),
PRIMARY KEY (id),
);

CREATE TABLE suppliers (
id int identity not null ,
CompanyName nvarchar(50),
CompanyAddress nvarchar(255),
CompanyPhone bigint not null,
PRIMARY KEY (id),
);

CREATE TABLE products (
id int identity not null,
ProductName nvarchar(50),
Productprice float,
SupplierID int not null,
PRIMARY KEY (id),
FOREIGN KEY (SupplierID) REFERENCES suppliers(id)
);

CREATE TABLE orders (
EmployeeId int not null,
ProductId int not null,
OrderDate date,
Quantity int not null,
PRIMARY KEY (EmployeeId,ProductId,OrderDate),
FOREIGN KEY (EmployeeId) REFERENCES employees(id),
FOREIGN KEY (ProductId) REFERENCES products(id),
);

za zad.2.
ALTER TABLE employees ADD EmployeeAddress nvarchar(255)
za zad.3.
INSERT INTO employees(EmpFirstName,EmplastName,EmployeeAddress)
VALUES ('Иван','Иванов','Хаджи Димитър 25'),
('Милена','Димитрова','Панайот Хитов 3'),
('Миглена','Панайотова', 'Васил Априлов' ),
('Васил','Трайков','Иван Вазов бл 4'),
('Димитринка', 'Станчева','Стефан Стамболов');

INSERT INTO suppliers (CompanyName,CompanyAddress,CompanyPhone)
VALUES ('Billa','Булевард България', 0700-120-10),
('T-market', 'Хаджи Димитър', 0700-340-20),
('Lidl', 'Христо Смирненски', 0700-560-10),
('Fantastico','Момина Сълза', 0700-324-10),
('Metro','Васил Априлов', 0700-247-27);

 

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY