Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6386615
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:02:55+00:00 2026-05-25T03:02:55+00:00

For example, a user create a product, and assign it into a category. In

  • 0

For example, a user create a product, and assign it into a category.

In the category, we have some record:

-phone, id:0
-computer, id:1
-pad, id:2

and a user create a product, the product need to assign a category, and a user do something like this:

name:iphone
cat:0

And the flow will work like this:

1.  check the cat is exist in db or not
2a. if not exist prompt error 
2b. if exist, put the record in db. 

But is there any chance when finished the step 1 checking, and before the 2b is start. The admin delete the phone category. If this happen, the database will insert a record which have no cat id watch. The db will have something like this:

*-phone, id:0* (not any more, because the admin delete it)
-computer, id:1
-pad, id:2

But there is a record like this:

name:iphone //but it belong to no category, because the admin delete it. 
cat:0

If there is a chance for doing this, how can I avoid this? Thank you.

(Using php and mysql with codeigniter)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T03:02:56+00:00Added an answer on May 25, 2026 at 3:02 am

    There are two things you should think about:

    1. Transactions – they make all changes atomic, i.e. all your changes are not visible for other users until you commit them, so everybody sees database in a consistent state.
    2. Modify your database schema to use foreign keys – they ensure that data relations are kept, so if you set it up so that category must always exist and it suddenly disappears then your insert will fail.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How do I create subdomain like http://user.mywebsite.example ? Do I have to access .htaccess
In this example, I create a user with no profile , then later on
I have a model defined as below: class Example(models.Model): user = models.ForeignKey(User, null=True) other
I have a database schema, where I have a Product , Category , CategoryFeature
I have to create an XML file dynamically based on the user input. Here
I have a need to allow for a user to download an event that
I have a product table that contains thousands of products. Some products are available
I've created a regular ASP.NET user control, including the ascx file. For example: MyUserControl.ascx
Example user input: PA1 9 //correct PJ1 9 //wrong, error printed Invalid row because
Example: The user login to the webpage => Click on a button This action

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.