i am working on my own database, trying to learning as much as i can on my days off only by research and Google's stuff!! I am doing a simply table, however there is few doubts. I really appreciate for any help!
I did try to use VARCHAR
instead INT
to get the reservation_code
from the form but i cannot use AUTO_INCREMET
on it. I get error! Reservation code should looks like this: 123AB
. Whats should i do?
CREATE TABLE flight
(
reservation_code VARCHAR(5) NOT NULL AUTO_INCREMENT,
flying_from VARCHAR(20) NOT NULL,
flying_to VARCHAR(20) NOT NULL,
PRIMARY KEY (reservation_code)
);
CREATE TABLE passenger
(
id INT NOT NULL AUTO_INCREMENT,
name VARCHAR(20) NOT NULL,
last_name VARCHAR(20) NOT NULL,
sex VARCHAR(1) NOT NULL,
PRIMARY KEY (id),
FOREING KEY (reservation_code) REFERENCES flight(reservation_code),
FOREING KEY (flight_date) REFERENCES flight_detail(flight_date),
FOREING KEY (bank_card) REFERENCES passenger_details(bank_card)
);
CREATE TABLE passenger_details
(
bank_card INT NOT NULL AUTO_INCREMENT,
email VARCHAR(20) NOT NULL,
mobile INT NOT NULL,
PRIMARY KEY (bank_card)
);
CREATE TABLE flight_detail
(
flight_date DATE NOT NULL AUTO_INCREMENT,
PRIMARY KEY (flight_date)
);