So I create my lil DB and then use the thing. I add two tables and now all I wanna do is this: when a user is inserted into the USERS table, also insert some default info into USER_ACCOUNT table that corresponds to the newly inserted user. Clearly I'm doing something wrong but I don't know what... Thanks in advance. =)
CREATE DATABASE REST_PROJECT;
USE REST_PROJECT;
CREATE TABLE USERS (
UserID INT Primary Key AUTO_INCREMENT NOT NULL,
UserEmail VARCHAR(30),
UserPassword VARCHAR(30)
);
CREATE TABLE USER_ACCOUNT (
UserAccountID INT Primary Key AUTO_INCREMENT NOT NULL,
OwnerUserID INT,
UserAccountName VARCHAR(30),
UserAccountType VARCHAR(10) NOT NULL,
UserAccountBalence INT,
FOREIGN KEY (OwnerUserID) REFERENCES USERS(UserID)
);
DELIMITER //
CREATE TRIGGER makeDefaultUserAccount
AFTER INSERT ON USERS
For each row
BEGIN
INSERT INTO USER_ACCOUNT
(UserAccountName, UserAccountType, UserAccountBalence)
values ('Default Account','default', 100);
END; //