version 3 need to work on foreign key cycle problem