Welcome Guest, Not a member yet? Register   Sign In
how to organize MySQL for portfolio site.
#1

[eluser]generalsalt[/eluser]
CI is awesome, and i am really starting to get the hang of it. One thing I cannot figure out is this:

How to organize MySQL for a site where you would have one title, one description, one thumbnail, BUT multiple images.

Do you create a table for JUST images. How do you associate the images with text/title/thumbnail that are presumably in another table?

And finally, how could you address this in CI?
#2

[eluser]Iván Argulo[/eluser]
Hi generalsalt.

I'd do this:


CREATE TABLE `portfolio` (
`id_portfolio` bigint(20) unsigned NOT NULL auto_increment,
`title` varchar(100) character set latin1 collate latin1_general_ci NOT NULL,
`description` mediumtext character set latin1 collate latin1_general_ci NOT NULL,
`thumbnail` varchar(100) character set latin1 collate latin1_general_ci NOT NULL,
PRIMARY KEY (`id_portfolio`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

CREATE TABLE `portfolio_images` (
`id_image` bigint(20) unsigned NOT NULL auto_increment,
`id_portfolio` bigint(20) unsigned NOT NULL,
`image_path` varchar(100) character set latin1 collate latin1_general_ci NOT NULL,
PRIMARY KEY (`id_image`),
KEY `k_id_portfolio` (`id_portfolio`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;




Theme © iAndrew 2016 - Forum software by © MyBB