Database operations: Edit table to online table update

Source: Internet
Author: User
Tags tagname

Requirements: Table edit needs to update the data to the table release, the inside will involve adding and removing the operation, how to do better??? 1, the edit table is the latest data, the release table is the online table. 2, there will be different containers call the release table, that is, the need to solve the lock between the container, the other containers only read operations, the container is being manipulated to read and write operations, because the update operation can not be atomic, so between operations may encounter other container query is empty or read half of the error state A. In the other table version, which table is used in the end. That is, the time to read the data is to jump back and forth between the two tables the following operations in the container we do update need to lock 1, update Version = edit, the other container read, the first look at the version to which the table, then read, 2, if you need to consider efficiency, Build a TMP table, insert the data in the edit into TMP, then delete the release table, and rename the TMP table to release.  3, unlock, and then need to update the time to repeat 1, the version first to release disadvantage: more cumbersome, while the update operation needs to lock. B. Analysis of business logic, in the end need to build two tables???? The best way is to maintain a table to re-comb the business logic, our original requirements are: 1, to each list to add the deletion of the modified sort "tag", when clicking on the release of the tag will need to update the changes to the line, scheme should be TagID, TagName, ListID , Sort,tagid increment of 2, the other container read classification is in the table to find the listid corresponding to all the "tag" 3, if the editor added a new tag, then there will be more than one tag on the line, there is a bug, so should add a status state enum to Online, OFFLINE, then the newly added tag for OFFLINE, when published to online, this will not affect the line 4, if the editor deleted a classification, in order not to affect the line, we can not delete this tag in the table, should add a valid state, Enum for valid, INVALID, delete directly hit INVALID can 5, modify tagname This operation can be converted to add and delete operations, first the previous tag valid state changed to INVALID, Then insert a tag that is the same as the original tag, but the name changed, but the previous tagid is the primary key, and now it repeats, so you need to add an increment ID as the primary key and CATID to random number. 6, sorting operations We default is the bubble method of the sort, then can also be converted to add and delete.

Database operations: Edit table to online table update

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.