Skip to content
Browse files

Try to hand-off all non-identifying one-to-ones if possible

  • Loading branch information...
1 parent f6d7889 commit 11deaae1b460526ee0c73a9a64e2968ed26ec501 @cjheath committed Dec 13, 2011
Showing with 6 additions and 0 deletions.
  1. +6 −0 lib/activefacts/persistence/tables.rb
View
6 lib/activefacts/persistence/tables.rb
@@ -237,6 +237,12 @@ def decide_tables #:nodoc:
}
debug :absorption, "#{object_type.name} has #{non_identifying_refs_from.size} non-identifying functional roles"
+ # If all non-identifying functional roles are one-to-ones that can be flipped, do that:
+ if non_identifying_refs_from.all? { |ref| ref.role_type == :one_one && (ref.to.is_table || ref.to.tentative) }
+ non_identifying_refs_from.each { |ref| ref.flip }
+ non_identifying_refs_from = []
+ end
+
if object_type.references_to.size > 1 and
non_identifying_refs_from.size > 0
debug :absorption, "#{object_type.name} has non-identifying functional dependencies so 3NF requires it be a table"

0 comments on commit 11deaae

Please sign in to comment.
Something went wrong with that request. Please try again.