This assumes only single-column foreign keys (continued at 246)...