Note that there are some explanatory texts on larger screens.

plurals
  1. PORelation Between Two Tables: make relationship between two tables
    primarykey
    data
    text
    <p>I have two tables as <strong>post</strong> and <strong>gallery</strong>, and i have made a relationship gallery to post table. My requirement is, When user upload content it store in the post table(content field) , If user upload the images are video i want to store the images/video name in, gallery table and the gallery id refers to the post table. I dont know how to do it. please any one help me?</p> <p><strong>post table:</strong></p> <pre class="lang-sql prettyprint-override"><code>CREATE TABLE IF NOT EXISTS `post` ( `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `user_id` bigint(20) unsigned NOT NULL, `gallery_id` bigint(20) unsigned NOT NULL, `content` longtext, `photo` varchar(128) DEFAULT NULL, `video` varchar(128) DEFAULT NULL, `created` timestamp NULL DEFAULT NULL, `updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`), KEY `fk_forum_post_user` (`user_id`), KEY `fk_forum_post_gallery` (`gallery_id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=10 ; ALTER TABLE `post` ADD CONSTRAINT `fk_post_gallery` FOREIGN KEY (`gallery_id`) REFERENCES `gallery` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, </code></pre> <p><strong>gallery table</strong></p> <pre class="lang-sql prettyprint-override"><code>CREATE TABLE IF NOT EXISTS `gallery` ( `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `user_id` bigint(20) unsigned NOT NULL, `type` int(11) NOT NULL DEFAULT '1' COMMENT '1- Photo, 2-Video, 3-Documents, 4-Unknown', `profile_picture` varchar(50) DEFAULT NULL, `forum_image` varchar(200) DEFAULT NULL, `forum_video` varchar(200) DEFAULT NULL, `forum_video_link` varchar(200) DEFAULT NULL, `created` timestamp NULL DEFAULT NULL, `updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`), KEY `fk_gallery_user` (`user_id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=60 ; </code></pre> <p>is any other idea is to do or how can i move forward? </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload