如何修复这些外键约束错误?

时间:2011-03-04 19:57:54

标签: sql

运行此sql脚本时出现这些错误:

错误:

  

错误代码-1,SQL状态23503:INSERT表'EVENT_SEAT_SET'   造成违反外键的行为   约束'SQL110304124417741'   键(Event_Seat_Set1
  )。声明已经滚动   背部。   第360行第1栏

脚本:

CREATE TABLE TicketSeller
(
id CHAR(40),
Name1  VARCHAR(50),
Address VARCHAR(100),
Telephone VARCHAR(10),
PRIMARY KEY (id)
);

CREATE TABLE Venue
(
id CHAR(40),
Owner VARCHAR(50),
PRIMARY KEY (id),
FOREIGN KEY (id) REFERENCES TicketSeller(id)
);

CREATE TABLE Venue_Configuration
(
id CHAR(40),
Name1 VARCHAR(50),
Description1 VARCHAR(255),
TotalSeats VARCHAR(50),
VenueID CHAR(40),
PRIMARY KEY (id),
FOREIGN KEY (VenueID) REFERENCES Venue(id)
);

CREATE TABLE SectionInVenue
(
id CHAR(40),
VenueID CHAR(40),
SectionNumber CHAR(40),
PRIMARY KEY (id),
FOREIGN KEY (VenueID) REFERENCES Venue(id)
);

CREATE TABLE RowInVenue
(
id CHAR(40),
SectionID CHAR(40),
RowNumber CHAR(40),
PRIMARY KEY (id),
FOREIGN KEY (SectionID) REFERENCES SectionInVenue(id)
);

CREATE TABLE Venue_Seat
(
id CHAR(40),
RowID CHAR(40),
SeatNumber CHAR(40),
PRIMARY KEY (id),
FOREIGN KEY (RowID) REFERENCES RowInVenue(id)
);

CREATE TABLE Venue_Production_Category
(
id CHAR(40),
Description1 VARCHAR(255),
Category VARCHAR(50),
DateTime DATE,
Morning DOUBLE,
Afternoon DOUBLE,
Evening DOUBLE,
VenueID CHAR(40),
PRIMARY KEY (id),
FOREIGN KEY (VenueID) REFERENCES Venue(id)
);

CREATE TABLE Production
(
id CHAR(40),
Name1  VARCHAR(50),
Description1 VARCHAR(255),
StartDate DATE,
EndDate DATE,
Comission DOUBLE,
CategoryID CHAR(40),
Venue_ConfigurationID CHAR(40),
PRIMARY KEY (id),
FOREIGN KEY (CategoryID) REFERENCES Venue_Production_Category(id),
FOREIGN KEY (Venue_ConfigurationID) REFERENCES Venue_Configuration(id)
);

CREATE TABLE TS_Owes_Venue
(
id CHAR(40),
AmountOwed DOUBLE,
TicketSellerid CHAR(40),
Venueid CHAR(40),
PRIMARY KEY (id),
FOREIGN KEY (TicketSellerid) REFERENCES TicketSeller(id),
FOREIGN KEY (Venueid) REFERENCES Venue(id)
);

CREATE TABLE TS_Payment
(
id CHAR(40),
DateReceived DATE,
TS_Owes_Venueid CHAR(40),
PaymentType VARCHAR(50),
PaymentAmt DOUBLE,
PRIMARY KEY (id),
FOREIGN KEY (TS_Owes_Venueid) REFERENCES TS_Owes_Venue(id)
);

CREATE TABLE Customer
(
id CHAR(40),
Name1  VARCHAR(50),
Address VARCHAR(100),
Telephone VARCHAR(12),
PRIMARY KEY (id)
);

CREATE TABLE Payment
(
id CHAR(40),
DateReceived DATE,
PaymentType VARCHAR(100),
PaymentAmt DOUBLE,
PRIMARY KEY (id)
);

CREATE TABLE Sale
(
id CHAR(40),
DateOfPurchase DATE,
Tax DOUBLE,
TotalPricePaid DOUBLE,
TicketSellerid CHAR(40),
Paymentid CHAR(40),
CustID CHAR(40),
PRIMARY KEY (id),
FOREIGN KEY (Paymentid) REFERENCES Payment(id),
FOREIGN KEY (TicketSellerid) REFERENCES TicketSeller(id),
FOREIGN KEY (CustID) REFERENCES Customer(id)
);

CREATE TABLE Sale_Item
(
id CHAR(40),
Discount DOUBLE,
Type1 VARCHAR(50),
StandardPrice DOUBLE,
PricePaid DOUBLE,
Commission DOUBLE,
SaleID CHAR(40),
VenueID CHAR(40),
PRIMARY KEY (id),
FOREIGN KEY (SaleID) REFERENCES Sale(id),
FOREIGN KEY (VenueID) REFERENCES Venue(id)
);

CREATE TABLE Event_Seat_Set
(
id CHAR(40),
PRIMARY KEY (id),
FOREIGN KEY (id) REFERENCES Sale_Item(id)
);

CREATE TABLE Physical_Pkg_Set
(
id CHAR(40),
PRIMARY KEY (id),
FOREIGN KEY (id) REFERENCES Sale_Item(id)
);

CREATE TABLE Conceptual_Package
(
id CHAR(40),
Name1 VARCHAR(50),
Description1 VARCHAR(255),
Discount DOUBLE,
VenueID CHAR(40),
PRIMARY KEY (id),
FOREIGN KEY (VenueID) REFERENCES Venue(id)
);

CREATE TABLE Physical_Package
(
id CHAR(40),
Status CHAR(40),
PhysPkgSetID CHAR(40),
ConceptualPackageID CHAR(40),
VenueSeatID CHAR(40),
PRIMARY KEY (id),
FOREIGN KEY (PhysPkgSetID) REFERENCES Physical_Pkg_Set(id),
FOREIGN KEY (ConceptualPackageID) REFERENCES Conceptual_Package(id),
FOREIGN KEY (VenueSeatID) REFERENCES Venue_Seat(id)
);

CREATE TABLE Event
(
id CHAR(40),
Name1 VARCHAR(50),
TheDate DATE,
BeginTime VARCHAR(50),
EndTime VARCHAR(50),
Status VARCHAR(50),
ProductionID CHAR(40),
Conceptual_PackageID CHAR(40),
VenueID CHAR(40),


PRIMARY KEY (id),
FOREIGN KEY (ProductionID) REFERENCES Production(id),
FOREIGN KEY (Conceptual_PackageID) REFERENCES Conceptual_Package(id),
FOREIGN KEY (VenueID) REFERENCES Venue(id)
);

CREATE TABLE EventSeat
(
id CHAR(40),
Price DOUBLE,
Status VARCHAR(50),
SetID CHAR(40),
EventID CHAR(40),
VenueSeatID CHAR(40),
PhysicalPackageID CHAR(40),
PRIMARY KEY (id),
FOREIGN KEY (SetID) REFERENCES Event_Seat_Set(id),
FOREIGN KEY (EventID) REFERENCES Event(id),
FOREIGN KEY (VenueSeatID) REFERENCES Venue_Seat(id),
FOREIGN KEY (PhysicalPackageID) REFERENCES Physical_Package(id)
);

CREATE TABLE Employee
(
id CHAR(40),
Name1 VARCHAR(50),
UserName1 VARCHAR(20),
Password VARCHAR(20),
Type VARCHAR(20),
PRIMARY KEY (id)
);

CREATE TABLE Pricing_Schema
(
id CHAR(40),
BasePrice DOUBLE,
DateTime DATE,
VPCid CHAR(40),
VenueSeatID CHAR(40),
PRIMARY KEY (id),
FOREIGN KEY (VPCid) REFERENCES Venue_Production_Category(id),
FOREIGN KEY (VenueSeatID) REFERENCES Venue_Seat(id)
);


INSERT INTO TicketSeller (id,Name1,Address,Telephone) VALUES ('TicketSeller1','Dominic Grant','479-1881 Tempus Street','7075205001');
INSERT INTO TicketSeller (id,Name1,Address,Telephone) VALUES ('TicketSeller2','Kennedy Perkins','698-1150 Non St.','3834072314');
INSERT INTO TicketSeller (id,Name1,Address,Telephone) VALUES ('TicketSeller3','Keaton Kidd','P.O. Box 990, 4639 Varius Ave','6252363833');
INSERT INTO TicketSeller (id,Name1,Address,Telephone) VALUES ('TicketSeller4','Basil Ryan','P.O. Box 918, 5123 Libero St.','4927231780');
INSERT INTO TicketSeller (id,Name1,Address,Telephone) VALUES ('TicketSeller5','Joshua Bell','Ap #392-5320 Phasellus St.','8612545635');

INSERT INTO Venue (id,Owner) VALUES ('TicketSeller1','Heather Singleton');
INSERT INTO Venue (id,Owner) VALUES ('TicketSeller2','Melodie Arnold');
INSERT INTO Venue (id,Owner) VALUES ('TicketSeller3','Buffy Gordon');
INSERT INTO Venue (id,Owner) VALUES ('TicketSeller4','Autumn Yang');
INSERT INTO Venue (id,Owner) VALUES ('TicketSeller5','Cynthia Fitzgerald');

INSERT INTO Venue_Configuration (id,Name1,Description1,TotalSeats,VenueID) VALUES ('Venue_Configuration1','at risus.','mattis velit justo nec ante. Maecenas mi felis, adipiscing fringilla, porttitor vulputate, posuere vulputate, lacus.','288','TicketSeller1');
INSERT INTO Venue_Configuration (id,Name1,Description1,TotalSeats,VenueID) VALUES ('Venue_Configuration2','molestie pharetra','fringilla purus mauris a nunc. In at pede. Cras vulputate velit eu sem. Pellentesque ut ipsum ac mi','64','TicketSeller1');
INSERT INTO Venue_Configuration (id,Name1,Description1,TotalSeats,VenueID) VALUES ('Venue_Configuration3','velit.','vitae velit egestas lacinia. Sed congue, elit sed consequat auctor, nunc nulla vulputate dui, nec tempus mauris erat eget ipsum. Suspendisse','94','TicketSeller1');
INSERT INTO Venue_Configuration (id,Name1,Description1,TotalSeats,VenueID) VALUES ('Venue_Configuration4','augue','sapien. Aenean massa. Integer vitae nibh. Donec est mauris, rhoncus id, mollis nec, cursus a, enim. Suspendisse aliquet, sem ut','573','TicketSeller4');
INSERT INTO Venue_Configuration (id,Name1,Description1,TotalSeats,VenueID) VALUES ('Venue_Configuration5','dignissim tempor','auctor, velit eget laoreet posuere, enim nisl elementum purus, accumsan interdum libero dui nec','761','TicketSeller5');

INSERT INTO SectionInVenue (id,SectionNumber,VenueID) VALUES ('SectionInVenue1','4','TicketSeller1');
INSERT INTO SectionInVenue (id,SectionNumber,VenueID) VALUES ('SectionInVenue2','16','TicketSeller2');
INSERT INTO SectionInVenue (id,SectionNumber,VenueID) VALUES ('SectionInVenue3','3','TicketSeller1');
INSERT INTO SectionInVenue (id,SectionNumber,VenueID) VALUES ('SectionInVenue4','19','TicketSeller1');
INSERT INTO SectionInVenue (id,SectionNumber,VenueID) VALUES ('SectionInVenue5','18','TicketSeller5');

INSERT INTO RowInVenue (id,RowNumber,SectionID) VALUES ('RowInVenue1','5','SectionInVenue1');
INSERT INTO RowInVenue (id,RowNumber,SectionID) VALUES ('RowInVenue2','3','SectionInVenue2');
INSERT INTO RowInVenue (id,RowNumber,SectionID) VALUES ('RowInVenue3','9','SectionInVenue1');
INSERT INTO RowInVenue (id,RowNumber,SectionID) VALUES ('RowInVenue4','1','SectionInVenue4');
INSERT INTO RowInVenue (id,RowNumber,SectionID) VALUES ('RowInVenue5','5','SectionInVenue1');

INSERT INTO Venue_Seat (id,SeatNumber,RowID) VALUES ('Venue_Seat1','33','RowInVenue1');
INSERT INTO Venue_Seat (id,SeatNumber,RowID) VALUES ('Venue_Seat2','49','RowInVenue2');
INSERT INTO Venue_Seat (id,SeatNumber,RowID) VALUES ('Venue_Seat3','40','RowInVenue1');
INSERT INTO Venue_Seat (id,SeatNumber,RowID) VALUES ('Venue_Seat4','27','RowInVenue4');
INSERT INTO Venue_Seat (id,SeatNumber,RowID) VALUES ('Venue_Seat5','5','RowInVenue1');

INSERT INTO Venue_Production_Category (id,Description1,Category,DateTime,Morning,Afternoon,Evening,VenueID) VALUES ('Venue_Production_Category1','12','metus urna','2011-04-26 16:41:05',100,110,140,'TicketSeller1');
INSERT INTO Venue_Production_Category (id,Description1,Category,DateTime,Morning,Afternoon,Evening,VenueID) VALUES ('Venue_Production_Category2','37','turpis vitae','2011-08-03 06:39:51',10,11,14,'TicketSeller2');
INSERT INTO Venue_Production_Category (id,Description1,Category,DateTime,Morning,Afternoon,Evening,VenueID) VALUES ('Venue_Production_Category3','20','non','2010-07-31 16:13:59',100.99,110.89,140.78,'TicketSeller3');
INSERT INTO Venue_Production_Category (id,Description1,Category,DateTime,Morning,Afternoon,Evening,VenueID) VALUES ('Venue_Production_Category4','31','nec luctus','2010-04-21 15:52:05',100.78,110.89,140.78,'TicketSeller4');
INSERT INTO Venue_Production_Category (id,Description1,Category,DateTime,Morning,Afternoon,Evening,VenueID) VALUES ('Venue_Production_Category5','32','lectus','2010-02-10 06:03:13',100.5,110.45,140.45,'TicketSeller5');

INSERT INTO Production (id,Name1,Description1,StartDate,EndDate,Comission,CategoryID,Venue_ConfigurationID) VALUES ('Production1','dolor.','eros turpis non enim. Mauris quis turpis vitae purus gravida sagittis. Duis gravida. Praesent eu nulla at sem molestie sodales.','2012-01-09 20:24:01','2010-12-20 02:43:01',.25,'Venue_Production_Category1','Venue_Configuration1');
INSERT INTO Production (id,Name1,Description1,StartDate,EndDate,Comission,CategoryID,Venue_ConfigurationID) VALUES ('Production2','at,','sed dolor. Fusce mi lorem, vehicula et, rutrum eu, ultrices sit amet, risus. Donec nibh enim,','2010-12-06 15:26:23','2010-03-25 21:32:48',.2,'Venue_Production_Category2','Venue_Configuration5');
INSERT INTO Production (id,Name1,Description1,StartDate,EndDate,Comission,CategoryID,Venue_ConfigurationID) VALUES ('Production3','lorem','condimentum eget, volutpat ornare, facilisis eget, ipsum. Donec sollicitudin adipiscing ligula. Aenean gravida nunc sed pede. Cum sociis','2011-11-11 07:50:27','2011-04-14 13:20:14',.1,'Venue_Production_Category3','Venue_Configuration2');
INSERT INTO Production (id,Name1,Description1,StartDate,EndDate,Comission,CategoryID,Venue_ConfigurationID) VALUES ('Production4','metus','mauris ipsum porta elit, a feugiat tellus lorem eu metus. In lorem. Donec elementum, lorem ut aliquam iaculis,','2011-09-23 14:29:58','2010-08-22 03:16:56',.15,'Venue_Production_Category4', 'Venue_Configuration3');
INSERT INTO Production (id,Name1,Description1,StartDate,EndDate,Comission,CategoryID,Venue_ConfigurationID) VALUES ('Production5','vel,','auctor quis, tristique ac, eleifend vitae, erat. Vivamus nisi. Mauris nulla. Integer urna. Vivamus molestie dapibus ligula. Aliquam erat volutpat. Nulla dignissim. Maecenas ornare','2011-10-07 13:47:35','2011-08-20 13:22:40',.15,'Venue_Production_Category5','Venue_Configuration4');

INSERT INTO TS_Owes_Venue (id,AmountOwed,TicketSellerid,Venueid) VALUES ('TS_Owes_TicketSeller1', 439,'TicketSeller1','TicketSeller5');
INSERT INTO TS_Owes_Venue (id,AmountOwed,TicketSellerid,Venueid) VALUES ('TS_Owes_TicketSeller2', 121,'TicketSeller2','TicketSeller3');
INSERT INTO TS_Owes_Venue (id,AmountOwed,TicketSellerid,Venueid) VALUES ('TS_Owes_TicketSeller3', 549,'TicketSeller3','TicketSeller4');
INSERT INTO TS_Owes_Venue (id,AmountOwed,TicketSellerid,Venueid) VALUES ('TS_Owes_TicketSeller4', 265,'TicketSeller4','TicketSeller2');
INSERT INTO TS_Owes_Venue (id,AmountOwed,TicketSellerid,Venueid) VALUES ('TS_Owes_TicketSeller5', 76,'TicketSeller5','TicketSeller1');

INSERT INTO TS_Payment (id,DateReceived,PaymentType,PaymentAmt,TS_Owes_Venueid) VALUES ('TS_Payment1','2009-09-02 08:49:15','sollicitudin orci',292,'TS_Owes_TicketSeller1');
INSERT INTO TS_Payment (id,DateReceived,PaymentType,PaymentAmt,TS_Owes_Venueid) VALUES ('TS_Payment2','2011-09-15 22:05:43','tristique',801,'TS_Owes_TicketSeller2');
INSERT INTO TS_Payment (id,DateReceived,PaymentType,PaymentAmt,TS_Owes_Venueid) VALUES ('TS_Payment3','2009-08-05 05:58:18','erat',735,'TS_Owes_TicketSeller3');
INSERT INTO TS_Payment (id,DateReceived,PaymentType,PaymentAmt,TS_Owes_Venueid) VALUES ('TS_Payment4','2010-01-30 05:20:23','a feugiat',744,'TS_Owes_TicketSeller4');
INSERT INTO TS_Payment (id,DateReceived,PaymentType,PaymentAmt,TS_Owes_Venueid) VALUES ('TS_Payment5','2011-11-03 03:16:52','eu elit.',268,'TS_Owes_TicketSeller5');

INSERT INTO Customer (id,Name1,Address,Telephone) VALUES ('Customer1','Igor Cervantes','654-2441 Nunc St.','435-768-0213');
INSERT INTO Customer (id,Name1,Address,Telephone) VALUES ('Customer2','Barry Farmer','902-5703 Et Rd.','577-435-7872');
INSERT INTO Customer (id,Name1,Address,Telephone) VALUES ('Customer3','Shad Barber','347-6930 Ipsum St.','285-317-5292');
INSERT INTO Customer (id,Name1,Address,Telephone) VALUES ('Customer4','Stone Hester','9147 Luctus, Road','232-801-5395');
INSERT INTO Customer (id,Name1,Address,Telephone) VALUES ('Customer5','Darius Battle','Ap #292-4270 Elit. Rd.','345-908-9273');

INSERT INTO Payment (id,DateReceived,PaymentType,PaymentAmt) VALUES ('Payment1','2011-04-06 19:18:25','mauris ut',179.89);
INSERT INTO Payment (id,DateReceived,PaymentType,PaymentAmt) VALUES ('Payment2','2009-03-18 17:28:45','ac',87.7);
INSERT INTO Payment (id,DateReceived,PaymentType,PaymentAmt) VALUES ('Payment3','2009-11-17 16:34:33','Maecenas',6.90);
INSERT INTO Payment (id,DateReceived,PaymentType,PaymentAmt) VALUES ('Payment4','2010-08-21 22:08:43','nulla',76.5);
INSERT INTO Payment (id,DateReceived,PaymentType,PaymentAmt) VALUES ('Payment5','2011-03-26 04:46:19','vel sapien',54.9);

INSERT INTO Sale (id,DateOfPurchase,Tax,TotalPricePaid,Paymentid,TicketSellerid,CustID) VALUES ('Sale1','2011-08-28 17:28:14',1.45,62.56,'Payment1','TicketSeller1','Customer1');
INSERT INTO Sale (id,DateOfPurchase,Tax,TotalPricePaid,Paymentid,TicketSellerid,CustID) VALUES ('Sale2','2011-02-08 15:03:15',6.80,7.50,'Payment2','TicketSeller2','Customer2');
INSERT INTO Sale (id,DateOfPurchase,Tax,TotalPricePaid,Paymentid,TicketSellerid,CustID) VALUES ('Sale3','2011-11-24 01:39:58',1.10,12.35,'Payment3','TicketSeller3','Customer3');
INSERT INTO Sale (id,DateOfPurchase,Tax,TotalPricePaid,Paymentid,TicketSellerid,CustID) VALUES ('Sale4','2011-01-06 23:06:57',2.40,62.56,'Payment4','TicketSeller4','Customer4');
INSERT INTO Sale (id,DateOfPurchase,Tax,TotalPricePaid,Paymentid,TicketSellerid,CustID) VALUES ('Sale5','2011-01-01 09:28:54',1.45,62.56,'Payment5','TicketSeller5','Customer5');

INSERT INTO Sale_Item (id,Discount,Type1,StandardPrice,PricePaid,Commission,SaleID,VenueID) VALUES ('Sale_Item1',20.00,'velit',45.00,25.00,6.80,'Sale1','TicketSeller3');
INSERT INTO Sale_Item (id,Discount,Type1,StandardPrice,PricePaid,Commission,SaleID,VenueID) VALUES ('Sale_Item2',10.00,'velit',40.00,33.00,4.40,'Sale5','TicketSeller4');
INSERT INTO Sale_Item (id,Discount,Type1,StandardPrice,PricePaid,Commission,SaleID,VenueID) VALUES ('Sale_Item3',3.00,'velit',35.00,20.00,7.30,'Sale3','TicketSeller2');
INSERT INTO Sale_Item (id,Discount,Type1,StandardPrice,PricePaid,Commission,SaleID,VenueID) VALUES ('Sale_Item4',5.00,'velit',50.00,47.00,2.50,'Sale4','TicketSeller1');
INSERT INTO Sale_Item (id,Discount,Type1,StandardPrice,PricePaid,Commission,SaleID,VenueID) VALUES ('Sale_Item5',6.00,'velit',25.00,12.00,6.10,'Sale2','TicketSeller5');

INSERT INTO Event_Seat_Set (id) VALUES ('Event_Seat_Set1');
INSERT INTO Event_Seat_Set (id) VALUES ('Event_Seat_Set2');
INSERT INTO Event_Seat_Set (id) VALUES ('Event_Seat_Set3');
INSERT INTO Event_Seat_Set (id) VALUES ('Event_Seat_Set4');
INSERT INTO Event_Seat_Set (id) VALUES ('Event_Seat_Set5');

INSERT INTO Physical_Pkg_Set (id) VALUES ('Physical_Pkg_Set1');
INSERT INTO Physical_Pkg_Set (id) VALUES ('Physical_Pkg_Set2');
INSERT INTO Physical_Pkg_Set (id) VALUES ('Physical_Pkg_Set3');
INSERT INTO Physical_Pkg_Set (id) VALUES ('Physical_Pkg_Set4');
INSERT INTO Physical_Pkg_Set (id) VALUES ('Physical_Pkg_Set5');

INSERT INTO Conceptual_Package (id,Name1,Description1,VenueID) VALUES ('Conceptual_Package1','egestas','eleifend non, dapibus rutrum, justo. Praesent luctus. Curabitur egestas nunc','TicketSeller3');
INSERT INTO Conceptual_Package (id,Name1,Description1,VenueID) VALUES ('Conceptual_Package2','Ut','Nunc mauris. Morbi non sapien molestie orci tincidunt adipiscing. Mauris molestie pharetra nibh.','TicketSeller3');
INSERT INTO Conceptual_Package (id,Name1,Description1,VenueID) VALUES ('Conceptual_Package3','Vivamus','accumsan sed, facilisis vitae, orci. Phasellus dapibus quam quis diam. Pellentesque habitant','TicketSeller4');
INSERT INTO Conceptual_Package (id,Name1,Description1,VenueID) VALUES ('Conceptual_Package4','egestas','tincidunt nibh. Phasellus nulla. Integer vulputate, risus a ultricies adipiscing, enim mi tempor lorem, eget mollis lectus pede et','TicketSeller5');
INSERT INTO Conceptual_Package (id,Name1,Description1,VenueID) VALUES ('Conceptual_Package5','arcu.','Nullam feugiat placerat velit. Quisque varius. Nam porttitor scelerisque neque. Nullam nisl. Maecenas malesuada fringilla est. Mauris eu turpis.','TicketSeller2');

INSERT INTO Physical_Package (id,Status,PhysPkgSetID,ConceptualPackageID,VenueSeatID) VALUES ('Physical_Package1','Open','Physical_Pkg_Set1','Conceptual_Package4','Venue_Seat2');
INSERT INTO Physical_Package (id,Status,PhysPkgSetID,ConceptualPackageID,VenueSeatID) VALUES ('Physical_Package2','Open','Physical_Pkg_Set3','Conceptual_Package1','Venue_Seat5');
INSERT INTO Physical_Package (id,Status,PhysPkgSetID,ConceptualPackageID,VenueSeatID) VALUES ('Physical_Package3','Open','Physical_Pkg_Set2','Conceptual_Package3','Venue_Seat1');
INSERT INTO Physical_Package (id,Status,PhysPkgSetID,ConceptualPackageID,VenueSeatID) VALUES ('Physical_Package4','Open','Physical_Pkg_Set5','Conceptual_Package2','Venue_Seat3');
INSERT INTO Physical_Package (id,Status,PhysPkgSetID,ConceptualPackageID,VenueSeatID) VALUES ('Physical_Package5','Open','Physical_Pkg_Set4','Conceptual_Package5','Venue_Seat4');

INSERT INTO Event (id,Name1,TheDate,BeginTime,EndTime,Status,ProductionID,Conceptual_PackageID,VenueID) VALUES ('Event1','Dave Mathews','2011-11-16 11:58:51','2011-04-24 00:44:18','2011-09-05 18:01:45','In','Production1','Conceptual_Package1','TicketSeller1');
INSERT INTO Event (id,Name1,TheDate,BeginTime,EndTime,Status,ProductionID,Conceptual_PackageID,VenueID) VALUES ('Event2','Jack Johsnon','2008-09-30 01:52:32','2011-03-17 01:15:34','2010-03-26 20:04:12','ipsum','Production2','Conceptual_Package2','TicketSeller2');
INSERT INTO Event (id,Name1,TheDate,BeginTime,EndTime,Status,ProductionID,Conceptual_PackageID,VenueID) VALUES ('Event3','Sweeeny Todd','2010-12-12 22:31:59','2010-03-27 23:53:10','2011-02-12 03:10:04','Sed eu','Production3','Conceptual_Package3','TicketSeller2');
INSERT INTO Event (id,Name1,TheDate,BeginTime,EndTime,Status,ProductionID,Conceptual_PackageID,VenueID) VALUES ('Event4','Run DMC','2010-05-04 08:14:51','2011-07-20 05:59:40','2011-04-26 23:27:27','ac','Production4','Conceptual_Package4','TicketSeller5');
INSERT INTO Event (id,Name1,TheDate,BeginTime,EndTime,Status,ProductionID,Conceptual_PackageID,VenueID) VALUES ('Event5','Jazz vs Nets','2011-08-14 01:31:53','2010-09-07 01:14:19','2011-12-14 08:21:50','ridiculus','Production5','Conceptual_Package5','TicketSeller3');

INSERT INTO EventSeat (id,Price,Status,SetID,EventID,VenueSeatID, PhysicalPackageID) VALUES ('EventSeat1',12.50,'Sold','Event_Seat_Set1','Event1','Venue_Seat1', 'Physical_Package1');
INSERT INTO EventSeat (id,Price,Status,SetID,EventID,VenueSeatID, PhysicalPackageID) VALUES ('EventSeat2',13.00,'Sold','Event_Seat_Set2','Event2','Venue_Seat2', 'Physical_Package2');
INSERT INTO EventSeat (id,Price,Status,SetID,EventID,VenueSeatID, PhysicalPackageID) VALUES ('EventSeat3',13.50,'Sold','Event_Seat_Set3','Event3','Venue_Seat3', 'Physical_Package3');
INSERT INTO EventSeat (id,Price,Status,SetID,EventID,VenueSeatID, PhysicalPackageID) VALUES ('EventSeat4',11.00,'Sold','Event_Seat_Set4','Event4','Venue_Seat4', 'Physical_Package4');
INSERT INTO EventSeat (id,Price,Status,SetID,EventID,VenueSeatID, PhysicalPackageID) VALUES ('EventSeat5',13.00,'Available','Event_Seat_Set5','Event5','Venue_Seat5', 'Physical_Package5');

INSERT INTO Employee (id,Name1,UserName1,Password,Type) VALUES ('Employee1','Boris Wilkins','Meredith','SPY20CST0NF','sed tortor.');
INSERT INTO Employee (id,Name1,UserName1,Password,Type) VALUES ('Employee2','Keaton Fowler','Camilla','VDT77CCG9OH','mus. Donec');
INSERT INTO Employee (id,Name1,UserName1,Password,Type) VALUES ('Employee3','Demetrius Dawson','Harrison','WEP92ISI8XY','quis accumsan');
INSERT INTO Employee (id,Name1,UserName1,Password,Type) VALUES ('Employee4','Cooper Woodward','Donovan','JSB18DKU7SJ','nec,');
INSERT INTO Employee (id,Name1,UserName1,Password,Type) VALUES ('Employee5','Kennedy Rivas','Scarlett','TJU06MIN3HJ','sociis natoque');


INSERT INTO Pricing_Schema (id,BasePrice,DateTime,VPCid,VenueSeatID) VALUES ('1',158,'2008-06-08 11:22:58','Venue_Production_Category1','Venue_Seat1');
INSERT INTO Pricing_Schema (id,BasePrice,DateTime,VPCid,VenueSeatID) VALUES ('2',152,'2011-07-15 18:51:26','Venue_Production_Category2','Venue_Seat2');
INSERT INTO Pricing_Schema (id,BasePrice,DateTime,VPCid,VenueSeatID) VALUES ('3',236,'2010-12-23 10:27:47','Venue_Production_Category3','Venue_Seat3');
INSERT INTO Pricing_Schema (id,BasePrice,DateTime,VPCid,VenueSeatID) VALUES ('4',184,'2011-10-07 03:59:21','Venue_Production_Category4','Venue_Seat4');
INSERT INTO Pricing_Schema (id,BasePrice,DateTime,VPCid,VenueSeatID) VALUES ('5',185,'2011-07-07 18:47:56','Venue_Production_Category5','Venue_Seat5');

4 个答案:

答案 0 :(得分:7)

Event_Seat_SetSale_Item的ID列引用为外键。

在向表中插入数据时,需要在表中插入现有的Sale_Item id。您没有向该字段插入任何内容,因此插入失败。

这也是其他表所发生的事情 - 错误告诉你究竟哪个表有外键以及它引用了哪个表(因此,插件中缺少哪些信息)。

说实话,我甚至不理解Event_Seat_Set的表格CREATE语句:

CREATE TABLE Event_Seat_Set
(
id CHAR(40),
PRIMARY KEY (id),
FOREIGN KEY (id) REFERENCES Sale_Item(id)
);

似乎表明该表只有一列 - ID,它既是主键,又引用id中的Sale_Item列。

这似乎不对。

答案 1 :(得分:2)

错误消息正好告诉您问题所在。插入记录时违反了外键约束。验证外键值是否正确(存在),然后重试脚本。

编辑:

这是你的一个问题:

INSERT INTO Event_Seat_Set (id) VALUES ('Event_Seat_Set1'); 
INSERT INTO Event_Seat_Set (id) VALUES ('Event_Seat_Set2'); 
INSERT INTO Event_Seat_Set (id) VALUES ('Event_Seat_Set3'); 
INSERT INTO Event_Seat_Set (id) VALUES ('Event_Seat_Set4'); 
INSERT INTO Event_Seat_Set (id) VALUES ('Event_Seat_Set5'); 

这些值必须是键(SaleItem表中存在的ID)。

BTW:我真的不喜欢你用过的架构。 IMO你应该使用整数(auto_inc)主键。虽然允许在char字段上创建主键,但这不可避免地会导致类似于您当前遇到的问题。

答案 2 :(得分:2)

Event_Seat_Set.id是PK,也是Sale_Item中的FK,它没有这些键:

INSERT INTO Sale_Item (id,Discount,Type1,StandardPrice,PricePaid,Commission,SaleID,VenueID) VALUES ('Sale_Item1',20.00,'velit',45.00,25.00,6.80,'Sale1','TicketSeller3');
INSERT INTO Sale_Item (id,Discount,Type1,StandardPrice,PricePaid,Commission,SaleID,VenueID) VALUES ('Sale_Item2',10.00,'velit',40.00,33.00,4.40,'Sale5','TicketSeller4');
INSERT INTO Sale_Item (id,Discount,Type1,StandardPrice,PricePaid,Commission,SaleID,VenueID) VALUES ('Sale_Item3',3.00,'velit',35.00,20.00,7.30,'Sale3','TicketSeller2');
INSERT INTO Sale_Item (id,Discount,Type1,StandardPrice,PricePaid,Commission,SaleID,VenueID) VALUES ('Sale_Item4',5.00,'velit',50.00,47.00,2.50,'Sale4','TicketSeller1');
INSERT INTO Sale_Item (id,Discount,Type1,StandardPrice,PricePaid,Commission,SaleID,VenueID) VALUES ('Sale_Item5',6.00,'velit',25.00,12.00,6.10,'Sale2','TicketSeller5');

INSERT INTO Event_Seat_Set (id) VALUES ('Event_Seat_Set1');
INSERT INTO Event_Seat_Set (id) VALUES ('Event_Seat_Set2');
INSERT INTO Event_Seat_Set (id) VALUES ('Event_Seat_Set3');
INSERT INTO Event_Seat_Set (id) VALUES ('Event_Seat_Set4');
INSERT INTO Event_Seat_Set (id) VALUES ('Event_Seat_Set5');

答案 3 :(得分:0)

看起来您没有在Event_Set_Seat和Physical_Pkg_Set表中插入外键。您必须插入这些,否则违反约束。看看http://www.w3schools.com/sql/sql_foreignkey.asp