dataset-examples icon indicating copy to clipboard operation
dataset-examples copied to clipboard

yelp_db.sql - Table "friend" should have two foreign keys

Open albertodelazzari opened this issue 7 years ago • 0 comments

Hi, I loaded Yelp dataset into MySQL and I inferred the schema from it. According to my understanding of the schema, the table "friend" should be a join table joining a user to another friend (user). So I expected to have two foreign keys one starting from 'friend.user_id' and pointing to 'user.id' and the second one starting from 'friend.friend_id' and pointing to 'user.id' as well.

CONSTRAINT `fk_friends_user1` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,  
CONSTRAINT `fk_friends_user2` FOREIGN KEY (`friend_id`) REFERENCES `user` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION

Does this make sense?

Thanks a lot.

albertodelazzari avatar Jan 05 '18 15:01 albertodelazzari