I was given a mySQL Database schema by my lecturer to create a banking app. There are some parts I don't understand.
CREATE SCHEMA Banking;
/* Customer Table */
DROP TABLE IF EXISTS Banking.Customer;
CREATE TABLE Banking.Customer(
custId int(11) AUTO_INCREMENT,
name varchar(50) NOT NULL,
address varchar(300) NOT NULL,
email varchar(100) NOT NULL,
phone int(11) DEFAULT NULL,
PRIMARY KEY (custId)
) ENGINE=InnoDB AUTO_INCREMENT=210590 DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS Banking.Account;
CREATE TABLE Banking.Account (
accountNo int(11) NOT NULL AUTO_INCREMENT,
cId int(11) NOT NULL,
balance int(11) NOT NULL,
sortCode int(11) NOT NULL,
PRIMARY KEY (accountNo),
KEY cId (cId),
KEY sortCode (sortCode),
CONSTRAINT account_ibfk_1
FOREIGN KEY (cid) REFERENCES Banking.CUSTOMER(custId)
) ENGINE=InnoDB AUTO_INCREMENT=816410 DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS Banking.Transaction;
CREATE TABLE Banking.Transaction (
_id int(11) NOT NULL AUTO_INCREMENT,
accountNo int(11) NOT NULL,
amount int(11) NOT NULL,
postBalance int(11) NOT NULL,
type varchar(255) DEFAULT NULL,
PRIMARY KEY (_id),
KEY accountNo (accountNo),
CONSTRAINT transaction_ibfk_2
FOREIGN KEY (accountNo) REFERENCES Account (accountNo)
) ENGINE=InnoDB AUTO_INCREMENT=229377 DEFAULT CHARSET=utf8;
My QUESTIONS are why is the ENGINE set to InnoDB
What are the constraints transaction_ibfk_2 and CONSTRAINT account_ibfk_1 doing.
Also the WORD Key.
Why are elements called KEY when they are neither a primary/foreign key?
Thanks