The first time to do the site, about the structure of the site want to ask on

Source: Internet
Author: User
The first time to do the site, about the structure of the site want to ask the next
This post was last edited by Xlrtx on 2013-03-11 20:23:40


A string of varying lengths (possibly an empty string) stored in the database or saved as a text file?
I do an online shopping site, each user will have a shopping cart

The Shopping Cart (CART) contains the items and items they put in the configuration,

The data structure stored in this cart (CART) is an array (I saved it in JSON format)

But because some users have put things have not put, so each user's shopping cart data length is not the same

Will the contents of the shopping cart (JSON data) be saved in the database or kept as a file?

If I save it as a database, do I put it inside the User.cart or in the Cart.items?

1) If put into Cart.items, the system will wait until the user adds items to the cart, add data to the cart, and assign the user's user.cart_id to Cart.id

When the user bar Cart.item empty, then user.cart_id=0, and delete the corresponding Cartrow

2) If you save to User.cart, each user will be allocated a long cart for storage, do not know will not waste resources? (I don't know the format of saving the database.)

3) If saved as a file, I will generate a $userid.json after each user registration success, put in a private folder, only the server can access, the contents of the content may be empty.
Database JSON


------Solution--------------------
The general website of the shopping cart is saved by the session or cookie.
Because it's a little bit better performance.
------Solution--------------------
1, the session from the default file mode to change to the database mode
2. Direct manipulation of $_session without JSON
3, in order to meet the "registered users need to be able to access the last login shopping Cart" in the session table to add a user name (user ID) field, and appropriate adjustment session callback function

So:
If you consider saving the non-checkout information in a database, the session table is already done. No more.
If you consider saving the non-checkout information with a file, the multi-tier catalog file management is difficult because of the huge number of accesses, and the single layer is too slow. Not the last resort, not the adoption
------Solution--------------------
Do not write programs for programs, it is to improve their own level of things to do

When doing real work, it is wrong to consider the technical process without figuring out the business process.
I'll just tell you a few mistakes in your mind.
1. Do not understand why to keep the shopping cart data, only to retain and retain
In fact, most people have accepted the fact that the re-login/drop-off shopping cart is emptied, as this is a complaint that the customer has hardly

2. "If someone gets the user's account password ...", the account password is much more important than the shopping cart data, putting the cart before the horse.
If I lose my account password, I'm not worried if someone sees a condom or a bimozhiyan in the shopping cart, but is worried about seeing my shipping address and consignee information.

3. The problem must be solved in the program
What should be solved in business logic, but carried down by the technical logic, is absolutely not the performance of doing business (doing things)

Shopping cart data is temporary data, complete a shopping (re-select also completed), the data is useless-or converted to order data
Now the biggest difference is only the time, that is the "completion process" time spent and many times the problem of browsing, by the way, the shopping cart inside the data for a few months also useful?
Sometimes in the case of limited technology, the problem should not be complicated, can do just do, can not do the honest feedback to the business logic layer to solve


If you want to turn Niu Jiao Jian, I'll give you a business logic problem:
I share a shopping account password with my family (probably not less than 3 people), alsoHow to solve the technical aspects of multi-point login, shopping and other goods to different locations or locations (different orders)? Description: Rejecting two logons is a business-level logic rather than a technical-level logic, I mean allow multi-point login how to do?

Just take the time to do the demand analysis and communicate with the Business Department is the most important
------Solution--------------------
A lot of Daniel.

I also want to do a similar website.

Mark's going to look later.

I'm still learning PHP and MySQL Web development, which is half of the book.
  • 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.