DROP TABLE MESSAGE;
DROP TABLE CONVERSATION;

CREATE TABLE CONVERSATION (ID INTEGER NOT NULL, STATUS VARCHAR(10), PRIMARY KEY (ID));
CREATE TABLE MESSAGE (ID INTEGER NOT NULL, MESSAGE VARCHAR(255), POSTINGDATE DATE, CONVERSATION_ID INTEGER, PRIMARY KEY (ID),
                      CONSTRAINT CONVERSATION_FK FOREIGN KEY (CONVERSATION_ID) REFERENCES CONVERSATION(ID));


INSERT INTO CONVERSATION (ID, STATUS) VALUES (1, 'ACTIVE');
INSERT INTO MESSAGE (ID, MESSAGE, POSTINGDATE, CONVERSATION_ID) VALUES (1, 'Hey', {d '2006-06-26'}, 1);
INSERT INTO MESSAGE (ID, MESSAGE, POSTINGDATE, CONVERSATION_ID) VALUES (2, 'How are you?', {d '2006-06-26'}, 1);
INSERT INTO MESSAGE (ID, MESSAGE, POSTINGDATE, CONVERSATION_ID) VALUES (3, 'Great!', {d '2006-06-26'}, 1);

INSERT INTO CONVERSATION (ID, STATUS) VALUES (2, 'ACTIVE');
INSERT INTO MESSAGE (ID, MESSAGE, POSTINGDATE, CONVERSATION_ID) VALUES (4, 'Have you finished yet?', {d '2006-06-20'}, 2);
INSERT INTO MESSAGE (ID, MESSAGE, POSTINGDATE, CONVERSATION_ID) VALUES (5, 'no.', {d '2006-06-20'}, 2);

INSERT INTO CONVERSATION (ID, STATUS) VALUES (3, 'ACTIVE');
INSERT INTO MESSAGE (ID, MESSAGE, POSTINGDATE, CONVERSATION_ID) VALUES (6, 'When is your birthday?', {d '2006-06-13'}, 3);
INSERT INTO MESSAGE (ID, MESSAGE, POSTINGDATE, CONVERSATION_ID) VALUES (7, 'Next week.', {d '2006-06-13'}, 3);
INSERT INTO MESSAGE (ID, MESSAGE, POSTINGDATE, CONVERSATION_ID) VALUES (8, 'How old will you be?', {d '2006-06-13'}, 3);
INSERT INTO MESSAGE (ID, MESSAGE, POSTINGDATE, CONVERSATION_ID) VALUES (9, '30', {d '2006-06-13'}, 3);

INSERT INTO CONVERSATION (ID, STATUS) VALUES (4, 'ACTIVE');
INSERT INTO MESSAGE (ID, MESSAGE, POSTINGDATE, CONVERSATION_ID) VALUES (10, 'Do you know a good query language?', {d '2006-05-22'}, 4);
INSERT INTO MESSAGE (ID, MESSAGE, POSTINGDATE, CONVERSATION_ID) VALUES (11, 'Sure. Try JPQL', {d '2006-05-22'}, 4);
INSERT INTO MESSAGE (ID, MESSAGE, POSTINGDATE, CONVERSATION_ID) VALUES (12, 'Thanks!', {d '2006-05-22'}, 4);

INSERT INTO CONVERSATION (ID, STATUS) VALUES (5, 'ACTIVE');
INSERT INTO MESSAGE (ID, MESSAGE, POSTINGDATE, CONVERSATION_ID) VALUES (13, 'Does EJB 3.0 support inheritance?', {d '2006-05-21'}, 5);
INSERT INTO MESSAGE (ID, MESSAGE, POSTINGDATE, CONVERSATION_ID) VALUES (14, 'Yes. See @Inheritance', {d '2006-05-21'}, 5);
INSERT INTO MESSAGE (ID, MESSAGE, POSTINGDATE, CONVERSATION_ID) VALUES (15, 'Ok.  What about polymorphism in the queries?', {d '2006-05-21'}, 5);
INSERT INTO MESSAGE (ID, MESSAGE, POSTINGDATE, CONVERSATION_ID) VALUES (16, 'It supports that too!', {d '2006-05-21'}, 5);
