Advertisement
Guest User

sql

a guest
Jul 2nd, 2013
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 1.53 KB | None | 0 0
  1. - --------------------------------------------------------
  2.  
  3. --
  4. -- Structure de la table `messages`
  5. --
  6.  
  7. CREATE TABLE IF NOT EXISTS `messages` (
  8.   `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  9.   `id_parent` int(10) unsigned DEFAULT NULL,
  10.   `id_sender` int(10) unsigned NOT NULL,
  11.   `id_receiver` int(10) unsigned NOT NULL,
  12.   `content` varchar(140) NOT NULL,
  13.   `date` datetime NOT NULL,
  14.   PRIMARY KEY (`id`),
  15.   KEY `id_parent` (`id_parent`),
  16.   KEY `id_sender` (`id_sender`),
  17.   KEY `id_receiver` (`id_receiver`)
  18. ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;
  19.  
  20. --
  21. -- Contenu de la table `messages`
  22. --
  23.  
  24. INSERT INTO `messages` (`id`, `id_parent`, `id_sender`, `id_receiver`, `content`, `date`) VALUES
  25. (1, NULL, 1, 2, 'All this bitchies wanna lick my icrecream', '2013-07-03 00:00:00'),
  26. (2, 1, 2, 2, 'tg', '2013-07-02 00:00:00');
  27.  
  28. --
  29. -- Contraintes pour les tables exportées
  30. --
  31.  
  32. --
  33. -- Contraintes pour la table `messages`
  34. --
  35. ALTER TABLE `messages`
  36.   ADD CONSTRAINT `messages_ibfk_1` FOREIGN KEY (`id_parent`) REFERENCES `messages` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  37.   ADD CONSTRAINT `messages_ibfk_2` FOREIGN KEY (`id_sender`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  38.   ADD CONSTRAINT `messages_ibfk_3` FOREIGN KEY (`id_receiver`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
  39.  
  40. /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
  41. /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
  42. /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement