The right way to handle lists like "StackoverflowQuestion tags",

Having the following tables:

  • Publish (identifier, title, text, etc.)
  • PostTag (PostId, TagId)
  • Tag (identifier, name)

Now the editing form (Internet solution) displays the " tags " associated with the message using the Jquery Select2 control , which allows you to use multiple entries. This input field returns a list of tags .

I think the correct way to handle these entries is:

  • an array loop with insert statement with no condition
  • and at the end, one delete statement does not exist (to remove tags that no longer exist).

Or is it better to delete everything and then insert a new list?

What about when there are fields ( ) in the PostTag table Id, PostId, TagId, CreatedOnthat allow you to repeat entries? I believe that either of the two previous methods is correct ... and all because the select2 control only returns a list of tag tags .

My question refers to the same logic that is used here in stackoverflow. Questions where we need to insert tags.

What is the correct logic for using this data type?

Note: The answer I'm looking for should take into account the efficiency and impact on the database (deletion effects (table locks) / updates), I say this because it is easy to make a functional solution that sucks everything else.

+4
3

. sharepoint .

  • :

    " , :
    insert
    delete ( , ).

  • " , ?"

, . , 100 .

8:00 , , . 100 101 . DML, , .. Auto ID PostTag, , 100 .

8:05 , , . 101 100 . , .

8:10 , , . 100 100 . , .

, , , . . , Stack Overflow, , Qaru , 10 000 , 10 000 10 ...

  1. , PostTag (Id, PostId, TagId, CreatedOn), ?

" , ". -. , .

CreateOn -, , ..

+2

, Tag. , . PostTag FK . , (PostTag)

, .

java () "", , , . ( , ). (, ..). Post, , .

, , , DELETE.

, .

, DELETE. - , .

, , PostTag createOn. , , ? , .

( , ) , . .

, , . , .

" Java, , / , " - "," # "," s " ..".

.

, .

0

:

  • .
  • .
  • Testing / debugging will be simpler because you know what you see is what you get. If the user interface has 4 tags and click "Save", you know that exactly what you get in the database
0
source

All Articles