Template
Message
Customer
Campaign
1
1
1
*
*
*
INSERT INTO customer (name, email)
VALUES (“Luís Cobucci”, “
[email protected]”);
SET @customer_id = LAST_INSERT_ID();
INSERT INTO template (name, body)
VALUES (“Template 1”, “blah… blah… blah…”);
INSERT INTO campaign (title, template_id, message)
VALUES (“Test”, LAST_INSERT_ID(), “blah… blah… blah…”);
INSERT INTO message (campaign_id, customer_id, sent)
VALUES (LAST_INSERT_ID(), @customer_id, FALSE);
Don’t forget to use a
transaction!