Jump to content

[SOLVED] Serialize or not to serialize...?


Yesideez

Recommended Posts

I'm making a database for a project I'm working on and I'm unsure which is the best method to use.

 

Basically I've got 10 locations and a list of about 15 or 20 items for sale in each location.

 

Is it best for me to add each item as a field in the locations table (so I can list each price for each item in each location) or to have a varchar for each location and serialize the contents into that?

 

Hope I've explained myself well enough... ;)

Link to comment
https://forums.phpfreaks.com/topic/54632-solved-serialize-or-not-to-serialize/
Share on other sites

This is my states table as it stands...

CREATE TABLE `states` (
  `stateid` tinyint(2) unsigned NOT NULL auto_increment,
  `name` varchar(9) NOT NULL,
  `abbrev` varchar(2) NOT NULL,
  PRIMARY KEY  (`stateid`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=11 ;

-- 
-- Dumping data for table `states`
-- 

INSERT INTO `states` VALUES (1, 'Arizona', 'AZ');
INSERT INTO `states` VALUES (2, 'Arkansas', 'AR');
INSERT INTO `states` VALUES (3, 'Colorado', 'CO');
INSERT INTO `states` VALUES (4, 'Idaho', 'ID');
INSERT INTO `states` VALUES (5, 'Minnesota', 'MN');
INSERT INTO `states` VALUES (6, 'Missouri', 'MO');
INSERT INTO `states` VALUES (7, 'Nevada', 'NV');
INSERT INTO `states` VALUES (8, 'Utah', 'UT');
INSERT INTO `states` VALUES (9, 'Wisconsin', 'WI');
INSERT INTO `states` VALUES (10, 'Wyoming', 'WY');

 

Just wondering if I should create about 15 or 20 extra fields with the names of each item for sale so I can list all the prices for all states or whether one varchar field would be better with the array serialized...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.