Text this: Deriving global and local integrity rules for a distributed database