How to design tag database structure?

Posted by liuxingruo on Stack Overflow See other posts from Stack Overflow or by liuxingruo
Published on 2010-05-09T14:36:19Z Indexed on 2010/05/09 14:38 UTC
Read the original article Hit count: 308

Filed under:
|
|

I have a subjects database, and I want to create a new tag database to tag the subjects, but I have no idea how to design the new tag database structure.

I'm assuming the new database looks like this:

tag_id  tag_name  tagged_subject_ids
1       tag1       1, 2, 3, 5, 10
2       tag2       2, 4, 5, 6, 10, 12

so, if I want to select the tags belong to subject 1:

SELECT tag_name FROM tag_database WHERE tagged_subject_ids LIKE '1';

I think the way that I select tag may be very slow, so please help me.

Thanks!

© Stack Overflow or respective owner

Related posts about mysql

Related posts about database