drop database if exists friendbook;

create database friendbook;

use friendbook;

create table login(
	username varchar(25),
	pword varchar(25),
	primary key(username));

create table contacts(
	username varchar(25),
	fname varchar(25),
	lnam varchar(25),
	primary key(username),
	foreign key(username) references login(username));

create table messages(
	messageID int,
	sender varchar(25),
	recipient varchar(25),
	message text,
	date date,
	haveread varchar(1),
	primary key(messageID),
	foreign key(sender) references contacts(username),
	foreign key(recipient) references contacts(username));

create table friendList(
	username varchar(25),
	friend varchar(25),
	confirm boolean);

insert into login
	values ('user1', 'password1');
insert into login
	values ('user2', 'password2');

insert into contacts
	values ('user1', 'num1', 'uno');
insert into contacts
	values ('user2', 'num2', 'dos');

insert into messages
	values ('1', 'user1', 'user2', 'hello, how are you', now(), 'Y');
insert into messages
	values ('2', 'user2', 'user1', 'im doing good, thanks', now(), 'N');
