Welcome Guest, Not a member yet? Register   Sign In
Managing TAGS for many different tables - Design Logic Help
#4

[eluser]Xeoncross[/eluser]
[quote author="gon" date="1219154892"]A table containing just 1 column: a site-wide ID. Let's call it RESOURCE_ID.[/quote]

So that would mean that you would do the following:

Code:
//Get post
SELECT * FROM `posts` where `id` = 1
//GET $row so we know what resource ID to get

//Get the resouce_ID so we can find the matching tags
SELECT * FROM `RESOURCE` WHERE `RESOURCE_ID` = '. $row['RESOURCE_ID'];
//Why bother though?

SELECT * FROM `tags` WHERE `RESOURCE_ID` = '. $row['RESOURCE_ID'];

I don't see any point at all in having a table with only one column since you would have to already know the resouce_id just to find it in the table. Wink

Plus, in the method I said there would never be two matching columns (like comments and posts) because you would use the "table" column to only fetch tags that matched the POST_ID and the table POSTS.


Freetag does kind of what I suggested.
Code:
CREATE TABLE freetags (
  id int(10) unsigned NOT NULL auto_increment,
  tag varchar(30) NOT NULL default '',
  raw_tag varchar(50) NOT NULL default '',
  PRIMARY KEY  (id)
) TYPE=MyISAM;

CREATE TABLE freetagged_objects (
  tag_id int(10) unsigned NOT NULL default '0',
  tagger_id int(10) unsigned NOT NULL default '0',
  object_id int(10) unsigned NOT NULL default '0',
  tagged_on datetime NOT NULL default '0000-00-00 00:00:00',
  PRIMARY KEY  (`tag_id`,`tagger_id`,`object_id`),
  KEY `tag_id_index` (`tag_id`),
  KEY `tagger_id_index` (`tagger_id`),
  KEY `object_id_index` (`object_id`)
) TYPE=MyISAM;


Messages In This Thread
Managing TAGS for many different tables - Design Logic Help - by El Forum - 08-19-2008, 11:23 AM



Theme © iAndrew 2016 - Forum software by © MyBB