In class, we are all 'studying' databases, and everyone is using Access. Bored with this, i am trying to do what the rest of the class is doing, but with raw SQL commands with mySQL instead of using Access.
I have managed to create databases and tables, but now how do i make a relationship between two tables?
If i have my two tables like this:
CREATE TABLE accounts(
account_id INT NOT NULL AUTO_INCREMENT,
customer_id INT( 4 ) NOT NULL ,
account_type ENUM( 'savings', 'credit' ) NOT NULL,
balance FLOAT( 9 ) NOT NULL,
PRIMARY KEY ( account_id )
)
and
CREATE TABLE customers(
customer_id INT NOT NULL AUTO_INCREMENT,
name VARCHAR(20) NOT NULL,
address VARCHAR(20) NOT NULL,
city VARCHAR(20) NOT NULL,
state VARCHAR(20) NOT NULL,
)
Now, how do i create a 'relationship' between the two tables. I want each account to be 'assigned' one customer_id (to indicate who owns it)?