How can I connect tables defined by $schema to each other?
I'm not sure what you mean by that, but possibly you're asking how to describe relationships between tables to the Schema API? Drupal has no support for that currently; there is a foreign keys
property available, but:
Foreign key definitions were added in Drupal 7 for documentation purposes only, and do not modify the database.
How do you insert data consistently into the database? Is there any possibility of having Transaction facilities in Drupal?
Yes, Drupal supports transactions. The API method to use is db_transaction()
:
$transaction = db_transaction();
try {
db_update('foo')...;
}
catch (Exception $e) {
$transaction->rollback();
// Recover
}