I am try to write the DDL script for a DB. I am trying to link the the fields area_number and seat_number with the table tickets

I keep getting the

Error Code: 1215. Cannot add foreign key constraint.

The table tickets will build, if I remove area_number and seat_number as FOREIGN KEYS.

-- Area:

CREATE TABLE area ( 
    venue_name VARCHAR(20) NOT NULL, 
    area_number INTEGER(5) NOT NULL, 
    seat_number INTEGER(5) NOT NULL, 
    PRIMARY KEY (venue_name),
    PRIMARY KEY (area_number),
    PRIMARY KEY (seat_number),
    FOREIGN KEY(venue_name) REFERENCES venue(venue_name) ON DELETE CASCADE); 

-- Tickets:

CREATE TABLE tickets( 
    ticket_code VARCHAR (20) NOT NULL, 
    venue_name VARCHAR (20) NOT NULL, 
    ticket_type VARCHAR (20) NOT NULL,
    event_name VARCHAR (60) NOT NULL,
    area_number INTEGER (5),
    seat_number INTEGER (5), 
    PRIMARY KEY(ticket_code), 
    FOREIGN KEY (ticket_type) REFERENCES ticket_type (ticket_type), 
    FOREIGN KEY (venue_name) REFERENCES venue (venue_name) ON DELETE CASCADE,
    FOREIGN KEY (event_name) REFERENCES _event (event_name) ON DELETE CASCADE,
    FOREIGN KEY (area_number) REFERENCES area (area_number),
    FOREIGN KEY (seat_number) REFERENCES area (seat_number));

Answers


Make sure area_number and seat_number are primary keys in area. A foreign key must reference a primary key in the target table.


Need Your Help

code 400, message Bad request syntax ('\x88\x80\xa32\xc9\x98')

python websocket novnc

noVNC websocket log shows above message on an authentication event. The authentication is always failing and noVNC is reporting subject error.

MSTest Reused codedUI

c# mstest coded-ui-tests

I have a series of MS Unit tests in a class that I have created called Forename. The all run and pass sucessfully to test a variety of inputs e.g 100 chars max etc