Updated sql model (enforcing referential integrity now)