+125
Set up a POST handler in your SparkDemo
class to handle incoming SMS messages from Twilio, as demonstrated in our session on 11 February. Get it to work with your own Twilio account, phone number, and an ngrok tunnel.
In class, we also collected ideas about the data model. I’d like you to try to implement the four main tables we identified using SQL.
Within IntelliJ, create two SQL files and store them in the resources
folder (but not within templates
). One should be called model.sql
and contain the CREATE TABLE
statements to set up all the tables.
The other should be called sample.sql
and contain several INSERT
statements to set up a sample user and a poll with some choices, and maybe some votes.
You should copy and paste your SQL into the H2 console to make sure it runs without errors. As a reminder of some of the SQL syntax, here are sample creation and insert statements for the table we used in Milestone 2:
create table user
( id int primary key auto_increment
, username varchar(45) not null
, email varchar(128)
, joined timestamp default now()
);
insert into user (username) values
('alice'),
('bob'),
('devi');
insert into user (username, email) values
('chris', 'league@example.com`);
In addition to the features you see there (such as primary key
, auto_increment
, not null
, default
, and now()
) you should consider how to set up foreign key attributes:
user_id int not null references user(id)