2

Current Structure

table [Tags]

TagID
TagName

table [Stores]

StoreID
StoreName
StoreCategory
StoreTagID

this will only make the store have one tag , how can I implement it to allow more than one tag I made tags group but not working also parsing but its usless like tagid:tagname,tagid:tagname...... for the same row but not efficient.

1

2 Answers 2

3

A common way to do this sort of thing is to create a third table e.g.

table [Store_Tags]

StoreID
TagID

Getting the tags for the Store then requires a join against Store_Tags to Tags e.g.

SELECT TagName FROM Tags INNER JOIN Store_Tags USING(TagID) WHERE StoreID = ?

An alternate approach would be to avoid using the Tag table and put the TagName directly in the Store_Tags table, it really depends how you intend to use the data.

Sign up to request clarification or add additional context in comments.

1 Comment

So the idea behind the Store_Tags table is that it enables you to have multiple tags for the store. Whenever you want to add a new tag to the store you insert a new row with the StoreID and the TagID of the new tag.
1

StackOverflow has all tags in separated DB table

Posts
  PostId
PostTags
  PostId
  TagId
Tgas
  TagId
  TagName

you can do similar

3 Comments

Have you a link to support that? Seems very unlikely to me as this can't be indexed making searches by tag inefficient.
Ah Ok. But notice they also have a PostTags table. That tag list is presumably a denormalised version of that.
@MartinSmith: ah yes, you're right. data.stackexchange.com/stackoverflow/q/111595 ... edited

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.