Updated sql generation

now handles schemas, notifies and multiple primary keys