SophiaPretty

(5)

$14/per page/Negotiable

About SophiaPretty

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Accounting,Algebra See all
Accounting,Algebra,Applied Sciences,Architecture and Design,Art & Design,Biology,Business & Finance,Calculus,Chemistry,Communications,Computer Science,Economics,Engineering,English,Environmental science,Essay writing Hide all
Teaching Since: Jul 2017
Last Sign in: 305 Weeks Ago, 1 Day Ago
Questions Answered: 15833
Tutorials Posted: 15827

Education

  • MBA,PHD, Juris Doctor
    Strayer,Devery,Harvard University
    Mar-1995 - Mar-2002

Experience

  • Manager Planning
    WalMart
    Mar-2001 - Feb-2009

Category > Computer Science Posted 16 Nov 2017 My Price 10.00

statement conflicted with the FOREIGN KEY constraint

I keep getting this ERROR:

 

The INSERT statement conflicted with the FOREIGN KEY constraint "fk_Customer_Rentals_Customers". The conflict occurred in database, table " Customers", column 'customer_id'.

 

 What can I do to fix this?

 

Background Info:

 

/* Customer_Rentals */

CREATE TABLE Customer_Rentals(

item_rental_id INT IDENTITY(1,1) NOT NULL,

customer_id INT NOT NULL,

movie_id INT NOT NULL,

rental_status_code INT NOT NULL,

rental_date_out DATE NULL,

rental_date_returned DATE NULL,

rental_amount_due MONEY NULL,

other_rental_details varchar(250) NULL);

 

/* Insert data for table Customer_Rentals*/

INSERT INTO Customer_Rentals VALUES (1, 2, 1, '2012/07/02', NULL, $2.50,'This movie is out');

INSERT INTO Customer_Rentals VALUES (2, 1, 2, NULL, NULL, NULL, 'This movie has been reserved');

 

 

/* Customers */

CREATE TABLE Customers(

customer_id INT IDENTITY(1,1) NOT NULL,

member_yn CHAR(3) NOT NULL,

membership_number CHAR(5) NOT NULL,

date_became_member DATE NOT NULL,

customer_first_name VARCHAR(32) NOT NULL,

customer_last_name VARCHAR(32) NOT NULL,

customer_address VARCHAR(128) NOT NULL,

customer_city VARCHAR(32) NOT NULL,

customer_state VARCHAR(2) NOT NULL,

customer_zip VARCHAR(12) NOT NULL,

customer_phone VARCHAR(13) NOT NULL,

customer_email VARCHAR (128) NOT NULL,

customer_dob DATE NOT NULL);

 

 

 

/* Insert data for table Customers */

INSERT INTO Customers VALUES ('100', 'M1001', '2010/01/05', 'John', 'Smith', '1235 Main St.', 'Dunmore', 'PA', '18512','752-242-6548', , '1955/02/01');

INSERT INTO Customers VALUES ('100', 'M1002', '2010/05/05', 'Mary', 'Jones', '235 Ardmore Blvd.', 'Pittsburgh', 'PA','15221', '412-535-8974', , '1955/02/02');

 

/* create primary keys with ALTER TABLE statement */

ALTER TABLE Customer_Rentals ADD CONSTRAINT pk_Customer_Rentals PRIMARY KEY (item_rental_id);

ALTER TABLE Customers ADD CONSTRAINT pk_Customers PRIMARY KEY (customer_id);

/* end of primary key creation */

 

/* create foreign keys */

ALTER TABLE Customer_Rentals ADD CONSTRAINT fk_Customer_Rentals_Customers FOREIGN KEY(customer_id)

REFERENCES Customers (customer_id);

/* END OF SCRIPT */

Answers

(5)
Status NEW Posted 16 Nov 2017 12:11 PM My Price 10.00

-----------  ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly

Not Rated(0)