fixes #2400 add foreign keys contraints to database tables