Mysql sequence fix & abstract behaviours

Hi Leo,

Managed to fix the issue with generating primary keys using sequences for mysql db. 
I also introduced an abstract RiceChange class to encompass all common behaviour such as obtaining foreign key references. Have a look and let me know. 

One issue I did experience and no workaround as of yet is validation - See todo for more details