Re: Dilemma over choosing right model table structure

2008-11-10 Thread teknoid

Are you using GUID's id's and foregin_keys?
If not, you could set yourself for some serious trouble down the road.

Also, take a look at the polymorphic behavior, I think it might be
some help here.

On Nov 8, 6:43 am, Marcus Silva <[EMAIL PROTECTED]> wrote:
> I think your solution is very good, but it does not suit my needs as
> the system I am building is rather complex.
>
> Instead I am going to use the following solution to store all my
> images:
>
> Images table:
> id
> foreign_id   //user_id
> associated_model //User...    -- Image->belongsTo = User/Shop/Album/
> Profile/More
> upload_comment // belongsTo $this->AssociatedModel->name
> filename
> full_path //stored in files.image.associated_model.filename
> has_thumb
> thumbs = serialized array  //small / large / medium / xlarge
> ext
> created
> updated
>
> -
>
> Then albums will have the following association:
>
> --Profile
> var $hasMany = array(
>         'Image' => array(
>                 'className' => 'Image',
>                 'foreignKey' => 'foreign_id', //profile_id
>                 'conditions' => array( 'Image.associated_model' => 'Profile'),
>         )
> );
>
> --Shop
> var $hasMany = array(
>         'Image' => array(
>                 'className' => 'Image',
>                 'foreignKey' => 'foreign_id', //shop_id
>                 'conditions' => array( 'Image.associated_model' => 'Shop'),
>         )
> );
>
> --Product
> var $hasAndBelongsToMany = array(
>         'Image' => array(
>                         'className'                             => 'Image',
>                         'joinTable'                     => 
> 'shop_images_products',
>                         'foreignKey'                    => 'product_id',
>                         'associationForeignKey'         => 'image_foreign_id',
>                         'fields'                                        => '',
>                         'conditions' => array( 'Image.associated_model' => 
> 'Shop'),
>                         'unique'                        => true,
>         )
> );
>
> Thats the solution I will be using, hope it works.
>
> I might even write a tutorial about this later
>
> Thank you all once again for helping out.
>
> On Nov 8, 8:21 am, Adam Royle <[EMAIL PROTECTED]> wrote:
>
> > Well, not really, you just need one images table for that.
>
> > Then in your models you just have an image_id, and set your
> > associations up like this:
>
> > class Shop extends AppModel {
>
> >         var $belongsTo = array(
> >                 'Image' => array('className' => 'Image', 'foreignKey' => 
> > 'image_id')
> >         );
>
> > }
>
> > class Album extends AppModel {
>
> >         var $belongsTo = array(
> >                 'Image' => array('className' => 'Image', 'foreignKey' => 
> > 'image_id')
> >         );
>
> > }
>
> > If you need more than one image associated, then just use a habtm
> > association and create a join table!
>
> > I've been using this method for over a year and a half and I've never
> > thought about doing it any other way.
>
> > Cheers,
> > Adam
>
> > On Nov 8, 9:29 am, Marcus Silva <[EMAIL PROTECTED]> wrote:
>
> > > That does help Adam.  Thats exactly the way I will do it now.
>
> > > But I think I will end up with many tables which is what really puts
> > > me off.  But thats not a problem.
>
> > > Should have ShopImage, AlbumImage ProfileImage and so on...
>
> > > Many thanks to all for helping out.
>
> > > Cheers
>
> > > On Nov 7, 10:42 pm, Adam Royle <[EMAIL PROTECTED]> wrote:
>
> > > > The way I do this:
>
> > > > Tables:
> > > > - images
> > > > - videos
> > > > - documents
>
> > > > Each of the tables has the standard fields like mime_type, filesize,
> > > > path, etc. And each custom type has any extra fields that may be
> > > > necessary (width, height, duration, bitrate, etc).
>
> > > > Behaviors:
> > > > - FileBehavior
> > > > - ImageBehavior extends FileBehavior
> > > > - VideoBehavior extends FileBehavior
>
> > > > The reason I split into multiple tables is for associations. Often I
> > > > want to control what media types are associated with my models. Eg. I
> > > > might want a model to have many images but just one video. Plus, this
> > > > prevents you from having to constantly check the media type if you're
> > > > iterating through one array with multiple media types.
>
> > > > Hope that helps.
>
> > > > Cheers,
> > > > Adam
>
> > > > On Nov 8, 3:06 am, Marcus Silva <[EMAIL PROTECTED]> wrote:
>
> > > > > Hi folks,
>
> > > > > I am trying to create system which will let users upload media to the
> > > > > server,  the question that I ask is weather using a single table to
> > > > > store the uploaded files is better than using separate tables to store
> > > > > each file type in terms of coding.
>
> > > > > Seems to me that if I use the multiple table I will be creating
> > > > > exactly the same data, but in a different table.
>
> > > > > Example:  audios,videos,images etc
>
> > > > > My

Re: Dilemma over choosing right model table structure

2008-11-08 Thread Marcus Silva

I think your solution is very good, but it does not suit my needs as
the system I am building is rather complex.

Instead I am going to use the following solution to store all my
images:

Images table:
id
foreign_id   //user_id
associated_model //User...-- Image->belongsTo = User/Shop/Album/
Profile/More
upload_comment // belongsTo $this->AssociatedModel->name
filename
full_path //stored in files.image.associated_model.filename
has_thumb
thumbs = serialized array  //small / large / medium / xlarge
ext
created
updated

-

Then albums will have the following association:

--Profile
var $hasMany = array(
'Image' => array(
'className' => 'Image',
'foreignKey' => 'foreign_id', //profile_id
'conditions' => array( 'Image.associated_model' => 'Profile'),
)
);

--Shop
var $hasMany = array(
'Image' => array(
'className' => 'Image',
'foreignKey' => 'foreign_id', //shop_id
'conditions' => array( 'Image.associated_model' => 'Shop'),
)
);

--Product
var $hasAndBelongsToMany = array(
'Image' => array(
'className' => 'Image',
'joinTable' => 
'shop_images_products',
'foreignKey'=> 'product_id',
'associationForeignKey' => 'image_foreign_id',
'fields'=> '',
'conditions' => array( 'Image.associated_model' => 
'Shop'),
'unique'=> true,
)
);

Thats the solution I will be using, hope it works.

I might even write a tutorial about this later

Thank you all once again for helping out.


On Nov 8, 8:21 am, Adam Royle <[EMAIL PROTECTED]> wrote:
> Well, not really, you just need one images table for that.
>
> Then in your models you just have an image_id, and set your
> associations up like this:
>
> class Shop extends AppModel {
>
> var $belongsTo = array(
> 'Image' => array('className' => 'Image', 'foreignKey' => 
> 'image_id')
> );
>
> }
>
> class Album extends AppModel {
>
> var $belongsTo = array(
> 'Image' => array('className' => 'Image', 'foreignKey' => 
> 'image_id')
> );
>
> }
>
> If you need more than one image associated, then just use a habtm
> association and create a join table!
>
> I've been using this method for over a year and a half and I've never
> thought about doing it any other way.
>
> Cheers,
> Adam
>
> On Nov 8, 9:29 am, Marcus Silva <[EMAIL PROTECTED]> wrote:
>
> > That does help Adam.  Thats exactly the way I will do it now.
>
> > But I think I will end up with many tables which is what really puts
> > me off.  But thats not a problem.
>
> > Should have ShopImage, AlbumImage ProfileImage and so on...
>
> > Many thanks to all for helping out.
>
> > Cheers
>
> > On Nov 7, 10:42 pm, Adam Royle <[EMAIL PROTECTED]> wrote:
>
> > > The way I do this:
>
> > > Tables:
> > > - images
> > > - videos
> > > - documents
>
> > > Each of the tables has the standard fields like mime_type, filesize,
> > > path, etc. And each custom type has any extra fields that may be
> > > necessary (width, height, duration, bitrate, etc).
>
> > > Behaviors:
> > > - FileBehavior
> > > - ImageBehavior extends FileBehavior
> > > - VideoBehavior extends FileBehavior
>
> > > The reason I split into multiple tables is for associations. Often I
> > > want to control what media types are associated with my models. Eg. I
> > > might want a model to have many images but just one video. Plus, this
> > > prevents you from having to constantly check the media type if you're
> > > iterating through one array with multiple media types.
>
> > > Hope that helps.
>
> > > Cheers,
> > > Adam
>
> > > On Nov 8, 3:06 am, Marcus Silva <[EMAIL PROTECTED]> wrote:
>
> > > > Hi folks,
>
> > > > I am trying to create system which will let users upload media to the
> > > > server,  the question that I ask is weather using a single table to
> > > > store the uploaded files is better than using separate tables to store
> > > > each file type in terms of coding.
>
> > > > Seems to me that if I use the multiple table I will be creating
> > > > exactly the same data, but in a different table.
>
> > > > Example:  audios,videos,images etc
>
> > > > My table structure:
>
> > > > CREATE TABLE `uploaded_files` (
> > > >   `id` int(11) unsigned NOT NULL auto_increment,
> > > >   `foreign_id` int(10) unsigned NOT NULL,
> > > >   `model` varchar(255) NOT NULL COMMENT 'Associated model name',
> > > >   `media` varchar(55) NOT NULL,
> > > >   `filename` varchar(255) default NULL,
> > > >   `ext` varchar(10) default NULL,
> > > >   `mime` varchar(55) default NULL,
> > > >   `filesize` int(11) NOT NULL,
> > > >   `webpath` varchar(255) NOT NULL C

Re: Dilemma over choosing right model table structure

2008-11-08 Thread Adam Royle

Well, not really, you just need one images table for that.

Then in your models you just have an image_id, and set your
associations up like this:

class Shop extends AppModel {

var $belongsTo = array(
'Image' => array('className' => 'Image', 'foreignKey' => 
'image_id')
);

}

class Album extends AppModel {

var $belongsTo = array(
'Image' => array('className' => 'Image', 'foreignKey' => 
'image_id')
);

}



If you need more than one image associated, then just use a habtm
association and create a join table!

I've been using this method for over a year and a half and I've never
thought about doing it any other way.

Cheers,
Adam

On Nov 8, 9:29 am, Marcus Silva <[EMAIL PROTECTED]> wrote:
> That does help Adam.  Thats exactly the way I will do it now.
>
> But I think I will end up with many tables which is what really puts
> me off.  But thats not a problem.
>
> Should have ShopImage, AlbumImage ProfileImage and so on...
>
> Many thanks to all for helping out.
>
> Cheers
>
> On Nov 7, 10:42 pm, Adam Royle <[EMAIL PROTECTED]> wrote:
>
> > The way I do this:
>
> > Tables:
> > - images
> > - videos
> > - documents
>
> > Each of the tables has the standard fields like mime_type, filesize,
> > path, etc. And each custom type has any extra fields that may be
> > necessary (width, height, duration, bitrate, etc).
>
> > Behaviors:
> > - FileBehavior
> > - ImageBehavior extends FileBehavior
> > - VideoBehavior extends FileBehavior
>
> > The reason I split into multiple tables is for associations. Often I
> > want to control what media types are associated with my models. Eg. I
> > might want a model to have many images but just one video. Plus, this
> > prevents you from having to constantly check the media type if you're
> > iterating through one array with multiple media types.
>
> > Hope that helps.
>
> > Cheers,
> > Adam
>
> > On Nov 8, 3:06 am, Marcus Silva <[EMAIL PROTECTED]> wrote:
>
> > > Hi folks,
>
> > > I am trying to create system which will let users upload media to the
> > > server,  the question that I ask is weather using a single table to
> > > store the uploaded files is better than using separate tables to store
> > > each file type in terms of coding.
>
> > > Seems to me that if I use the multiple table I will be creating
> > > exactly the same data, but in a different table.
>
> > > Example:  audios,videos,images etc
>
> > > My table structure:
>
> > > CREATE TABLE `uploaded_files` (
> > >   `id` int(11) unsigned NOT NULL auto_increment,
> > >   `foreign_id` int(10) unsigned NOT NULL,
> > >   `model` varchar(255) NOT NULL COMMENT 'Associated model name',
> > >   `media` varchar(55) NOT NULL,
> > >   `filename` varchar(255) default NULL,
> > >   `ext` varchar(10) default NULL,
> > >   `mime` varchar(55) default NULL,
> > >   `filesize` int(11) NOT NULL,
> > >   `webpath` varchar(255) NOT NULL COMMENT 'Web path to show file',
> > >   `full_path` text NOT NULL COMMENT 'Full path to file_src',
> > >   `hasThumb` tinyint(1) unsigned NOT NULL,
> > >   `thumbs` text,
> > >   `width` int(11) default NULL,
> > >   `height` int(11) default NULL,
> > >   `description` varchar(155) default NULL,
> > >   `created` datetime default NULL,
> > >   `updated` datetime default NULL,
> > >   PRIMARY KEY  (`id`)
> > > ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
>
> > > Basically, I am looking for an easy solution that will reduce the
> > > amount of code I write
>
> > > Hope some of you guys can help.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Dilemma over choosing right model table structure

2008-11-07 Thread Sergei

I think better to make one table for all content types. And make a
content_type column or something. It will be faster and easier to work
with such model.


On 8 нояб, 01:06, Marcus Silva <[EMAIL PROTECTED]> wrote:
> Hi folks,
>
> I am trying to create system which will let users upload media to the
> server,  the question that I ask is weather using a single table to
> store the uploaded files is better than using separate tables to store
> each file type in terms of coding.
>
> Seems to me that if I use the multiple table I will be creating
> exactly the same data, but in a different table.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Dilemma over choosing right model table structure

2008-11-07 Thread Dr. Tarique Sani

On Sat, Nov 8, 2008 at 6:01 AM, rgreenphotodesign
<[EMAIL PROTECTED]> wrote:
>
> For images(photos specifically) do you store the exif data as well?
>

If not using native PHP exif functions extracting exif every time is
expensive - I prefer to extract, sanitize, serialize and store it in
DB

Tarique

-- 
=
Cheesecake-Photoblog: http://cheesecake-photoblog.org
PHP for E-Biz: http://sanisoft.com
=

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Dilemma over choosing right model table structure

2008-11-07 Thread rgreenphotodesign

For images(photos specifically) do you store the exif data as well?

On Nov 7, 4:29 pm, Marcus Silva <[EMAIL PROTECTED]> wrote:
> That does help Adam.  Thats exactly the way I will do it now.
>
> But I think I will end up with many tables which is what really puts
> me off.  But thats not a problem.
>
> Should have ShopImage, AlbumImage ProfileImage and so on...
>
> Many thanks to all for helping out.
>
> Cheers
>
> On Nov 7, 10:42 pm, Adam Royle <[EMAIL PROTECTED]> wrote:
>
> > The way I do this:
>
> > Tables:
> > - images
> > - videos
> > - documents
>
> > Each of the tables has the standard fields like mime_type, filesize,
> > path, etc. And each custom type has any extra fields that may be
> > necessary (width, height, duration, bitrate, etc).
>
> > Behaviors:
> > - FileBehavior
> > - ImageBehavior extends FileBehavior
> > - VideoBehavior extends FileBehavior
>
> > The reason I split into multiple tables is for associations. Often I
> > want to control what media types are associated with my models. Eg. I
> > might want a model to have many images but just one video. Plus, this
> > prevents you from having to constantly check the media type if you're
> > iterating through one array with multiple media types.
>
> > Hope that helps.
>
> > Cheers,
> > Adam
>
> > On Nov 8, 3:06 am, Marcus Silva <[EMAIL PROTECTED]> wrote:
>
> > > Hi folks,
>
> > > I am trying to create system which will let users upload media to the
> > > server,  the question that I ask is weather using a single table to
> > > store the uploaded files is better than using separate tables to store
> > > each file type in terms of coding.
>
> > > Seems to me that if I use the multiple table I will be creating
> > > exactly the same data, but in a different table.
>
> > > Example:  audios,videos,images etc
>
> > > My table structure:
>
> > > CREATE TABLE `uploaded_files` (
> > >   `id` int(11) unsigned NOT NULL auto_increment,
> > >   `foreign_id` int(10) unsigned NOT NULL,
> > >   `model` varchar(255) NOT NULL COMMENT 'Associated model name',
> > >   `media` varchar(55) NOT NULL,
> > >   `filename` varchar(255) default NULL,
> > >   `ext` varchar(10) default NULL,
> > >   `mime` varchar(55) default NULL,
> > >   `filesize` int(11) NOT NULL,
> > >   `webpath` varchar(255) NOT NULL COMMENT 'Web path to show file',
> > >   `full_path` text NOT NULL COMMENT 'Full path to file_src',
> > >   `hasThumb` tinyint(1) unsigned NOT NULL,
> > >   `thumbs` text,
> > >   `width` int(11) default NULL,
> > >   `height` int(11) default NULL,
> > >   `description` varchar(155) default NULL,
> > >   `created` datetime default NULL,
> > >   `updated` datetime default NULL,
> > >   PRIMARY KEY  (`id`)
> > > ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
>
> > > Basically, I am looking for an easy solution that will reduce the
> > > amount of code I write
>
> > > Hope some of you guys can help.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Dilemma over choosing right model table structure

2008-11-07 Thread Marcus Silva

That does help Adam.  Thats exactly the way I will do it now.

But I think I will end up with many tables which is what really puts
me off.  But thats not a problem.

Should have ShopImage, AlbumImage ProfileImage and so on...

Many thanks to all for helping out.

Cheers


On Nov 7, 10:42 pm, Adam Royle <[EMAIL PROTECTED]> wrote:
> The way I do this:
>
> Tables:
> - images
> - videos
> - documents
>
> Each of the tables has the standard fields like mime_type, filesize,
> path, etc. And each custom type has any extra fields that may be
> necessary (width, height, duration, bitrate, etc).
>
> Behaviors:
> - FileBehavior
> - ImageBehavior extends FileBehavior
> - VideoBehavior extends FileBehavior
>
> The reason I split into multiple tables is for associations. Often I
> want to control what media types are associated with my models. Eg. I
> might want a model to have many images but just one video. Plus, this
> prevents you from having to constantly check the media type if you're
> iterating through one array with multiple media types.
>
> Hope that helps.
>
> Cheers,
> Adam
>
> On Nov 8, 3:06 am, Marcus Silva <[EMAIL PROTECTED]> wrote:
>
> > Hi folks,
>
> > I am trying to create system which will let users upload media to the
> > server,  the question that I ask is weather using a single table to
> > store the uploaded files is better than using separate tables to store
> > each file type in terms of coding.
>
> > Seems to me that if I use the multiple table I will be creating
> > exactly the same data, but in a different table.
>
> > Example:  audios,videos,images etc
>
> > My table structure:
>
> > CREATE TABLE `uploaded_files` (
> >   `id` int(11) unsigned NOT NULL auto_increment,
> >   `foreign_id` int(10) unsigned NOT NULL,
> >   `model` varchar(255) NOT NULL COMMENT 'Associated model name',
> >   `media` varchar(55) NOT NULL,
> >   `filename` varchar(255) default NULL,
> >   `ext` varchar(10) default NULL,
> >   `mime` varchar(55) default NULL,
> >   `filesize` int(11) NOT NULL,
> >   `webpath` varchar(255) NOT NULL COMMENT 'Web path to show file',
> >   `full_path` text NOT NULL COMMENT 'Full path to file_src',
> >   `hasThumb` tinyint(1) unsigned NOT NULL,
> >   `thumbs` text,
> >   `width` int(11) default NULL,
> >   `height` int(11) default NULL,
> >   `description` varchar(155) default NULL,
> >   `created` datetime default NULL,
> >   `updated` datetime default NULL,
> >   PRIMARY KEY  (`id`)
> > ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
>
> > Basically, I am looking for an easy solution that will reduce the
> > amount of code I write
>
> > Hope some of you guys can help.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Dilemma over choosing right model table structure

2008-11-07 Thread Adam Royle

The way I do this:

Tables:
- images
- videos
- documents

Each of the tables has the standard fields like mime_type, filesize,
path, etc. And each custom type has any extra fields that may be
necessary (width, height, duration, bitrate, etc).

Behaviors:
- FileBehavior
- ImageBehavior extends FileBehavior
- VideoBehavior extends FileBehavior

The reason I split into multiple tables is for associations. Often I
want to control what media types are associated with my models. Eg. I
might want a model to have many images but just one video. Plus, this
prevents you from having to constantly check the media type if you're
iterating through one array with multiple media types.

Hope that helps.

Cheers,
Adam


On Nov 8, 3:06 am, Marcus Silva <[EMAIL PROTECTED]> wrote:
> Hi folks,
>
> I am trying to create system which will let users upload media to the
> server,  the question that I ask is weather using a single table to
> store the uploaded files is better than using separate tables to store
> each file type in terms of coding.
>
> Seems to me that if I use the multiple table I will be creating
> exactly the same data, but in a different table.
>
> Example:  audios,videos,images etc
>
> My table structure:
>
> CREATE TABLE `uploaded_files` (
>   `id` int(11) unsigned NOT NULL auto_increment,
>   `foreign_id` int(10) unsigned NOT NULL,
>   `model` varchar(255) NOT NULL COMMENT 'Associated model name',
>   `media` varchar(55) NOT NULL,
>   `filename` varchar(255) default NULL,
>   `ext` varchar(10) default NULL,
>   `mime` varchar(55) default NULL,
>   `filesize` int(11) NOT NULL,
>   `webpath` varchar(255) NOT NULL COMMENT 'Web path to show file',
>   `full_path` text NOT NULL COMMENT 'Full path to file_src',
>   `hasThumb` tinyint(1) unsigned NOT NULL,
>   `thumbs` text,
>   `width` int(11) default NULL,
>   `height` int(11) default NULL,
>   `description` varchar(155) default NULL,
>   `created` datetime default NULL,
>   `updated` datetime default NULL,
>   PRIMARY KEY  (`id`)
> ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
>
> Basically, I am looking for an easy solution that will reduce the
> amount of code I write
>
> Hope some of you guys can help.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Dilemma over choosing right model table structure

2008-11-07 Thread teknoid

if it's always going to be the same data, then you should go with a
single table, and designate media_type column...
on the other hand i see that you have a column hasThumb (or
has_thumb)... that obviously cannot apply to audio.

On Nov 7, 12:06 pm, Marcus Silva <[EMAIL PROTECTED]> wrote:
> Hi folks,
>
> I am trying to create system which will let users upload media to the
> server,  the question that I ask is weather using a single table to
> store the uploaded files is better than using separate tables to store
> each file type in terms of coding.
>
> Seems to me that if I use the multiple table I will be creating
> exactly the same data, but in a different table.
>
> Example:  audios,videos,images etc
>
> My table structure:
>
> CREATE TABLE `uploaded_files` (
>   `id` int(11) unsigned NOT NULL auto_increment,
>   `foreign_id` int(10) unsigned NOT NULL,
>   `model` varchar(255) NOT NULL COMMENT 'Associated model name',
>   `media` varchar(55) NOT NULL,
>   `filename` varchar(255) default NULL,
>   `ext` varchar(10) default NULL,
>   `mime` varchar(55) default NULL,
>   `filesize` int(11) NOT NULL,
>   `webpath` varchar(255) NOT NULL COMMENT 'Web path to show file',
>   `full_path` text NOT NULL COMMENT 'Full path to file_src',
>   `hasThumb` tinyint(1) unsigned NOT NULL,
>   `thumbs` text,
>   `width` int(11) default NULL,
>   `height` int(11) default NULL,
>   `description` varchar(155) default NULL,
>   `created` datetime default NULL,
>   `updated` datetime default NULL,
>   PRIMARY KEY  (`id`)
> ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
>
> Basically, I am looking for an easy solution that will reduce the
> amount of code I write
>
> Hope some of you guys can help.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Dilemma over choosing right model table structure

2008-11-07 Thread Marcus Silva

Hi folks,

I am trying to create system which will let users upload media to the
server,  the question that I ask is weather using a single table to
store the uploaded files is better than using separate tables to store
each file type in terms of coding.

Seems to me that if I use the multiple table I will be creating
exactly the same data, but in a different table.

Example:  audios,videos,images etc

My table structure:

CREATE TABLE `uploaded_files` (
  `id` int(11) unsigned NOT NULL auto_increment,
  `foreign_id` int(10) unsigned NOT NULL,
  `model` varchar(255) NOT NULL COMMENT 'Associated model name',
  `media` varchar(55) NOT NULL,
  `filename` varchar(255) default NULL,
  `ext` varchar(10) default NULL,
  `mime` varchar(55) default NULL,
  `filesize` int(11) NOT NULL,
  `webpath` varchar(255) NOT NULL COMMENT 'Web path to show file',
  `full_path` text NOT NULL COMMENT 'Full path to file_src',
  `hasThumb` tinyint(1) unsigned NOT NULL,
  `thumbs` text,
  `width` int(11) default NULL,
  `height` int(11) default NULL,
  `description` varchar(155) default NULL,
  `created` datetime default NULL,
  `updated` datetime default NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;


Basically, I am looking for an easy solution that will reduce the
amount of code I write

Hope some of you guys can help.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---