How do I define the attribution module for some fields?

Source: Internet
Author: User
In the design of the commodity module, there is a demand that some goods are not able to participate in activities. There are two options for designing a product model at this time:

    • This attribute is placed on the commodity model and is maintained by the commodity module.

    • Commodity module Regardless of this limited purchase attribute, the Activity module records the limited purchase, maintains a limited purchase item ID table

Personally, these two ways can be, but if the restriction of the purchase of this attribute on the commodity model, the future of this special attribute more and more, will lead to unlimited expansion of commodity models. So if the relationship is managed by a promotion, there are only a few simple attributes on the commodity model, and the basic service will be cleaner.

Is there any experience or criteria that can be consulted? Thank you.

Reply content:

In the design of the commodity module, there is a demand that some goods are not able to participate in activities. There are two options for designing a product model at this time:

    • This attribute is placed on the commodity model and is maintained by the commodity module.

    • Commodity module Regardless of this limited purchase attribute, the Activity module records the limited purchase, maintains a limited purchase item ID table

Personally, these two ways can be, but if the restriction of the purchase of this attribute on the commodity model, the future of this special attribute more and more, will lead to unlimited expansion of commodity models. So if the relationship is managed by a promotion, there are only a few simple attributes on the commodity model, and the basic service will be cleaner.

Is there any experience or criteria that can be consulted? Thank you.

I basically agree with the method of the @ border town.
Goods, activities, and limited purchases are all facts that need to be recorded. The key question is how to express "limited purchase".
Because the purchase limit itself may also contain other attributes, such as the purchase date and so on, so it is not a single association table (many-to-many relationships) can be solved.

There are two ways to record a limit purchase: 1) record unlimited purchases of goods, activities 2) record limited purchases of merchandise activities
If the number of goods purchased is relatively small, Method 2) is more appropriate.

Product (ProductId, ...)
Activity (ActivityID, ...)
Purchaserestriction (ProductId, ActivityID, StartDate, EndDate, ...)

Your question:
1. This mapping table, which module to maintain
Goods, activities are not independent of each other, purchaserestriction precisely represents the link between them.
Purchaserestriction is both product-related and activity-related. is not a simple "who's property".
Many people use circular references when designing class, for example, Product has a Restrictedactivities collection, and Activity has a restrictedproducts collection.
You have a similar question in mind, on the one hand, that the purchase limit is a fact, should only be placed in one place; on the other hand, the feeling of limited purchase is both the property of product and the property of activity.

I think that this is a disadvantage of object-oriented, "object owning property, property must belong to an object" the root of the idea is that everything is a tree structure .
This makes the same mistake as the tree database, which later appears on the network database. Network databases can express complex structures, but are too complex.
The emergence of relational database solves the problem of tree database and network database. Relational database is a model based on set theory and first order predicate logic, which can express various structures perfectly.

"Modularity" is of course very good, and reasonable modularity reduces the coupling between each module of the program.
However, the maximum coupling of a system is often the coupling of programs and data. The structure of the data has changed and the program must be changed.
Therefore, a standardized database design is more important than the modularity of the application.

You put the goods and activities into different modules, on the one hand, improve the level of abstraction, modularity, on the other hand, the separation of their relations. Although there are many modules, the interaction between modules is more complex.
There is no perfect answer to your question, there are 3 solutions:
A) commodity module to maintain
b) Active module to maintain
c) separate modules to maintain.

2. The above mentioned (whether the goods can participate in activities, goods limited purchase properties), I think the first one can be classified as a commodity intrinsic properties, the second may be recorded by a mapping table (because the limited purchase of goods is a few)
Whether the product can participate in the activity can be deduced by purchaserestriction, which does not require such a property.
In a program, there may be a class that has a property cantakepartinactivity. However, the database cannot be designed this way.

In general, it is recommended to use a table of goods and activities to record, and then through a relationship table to establish a link, so whether from the product search activities or activities to find products are more convenient. For situations in which recent activity requires fast reading, you can even set up cached data separately for the activity to improve read efficiency.

Detailed analysis of the specific situation, if the merchandise any activities are not to participate, it is directly placed in the commodity table can be, but if a commodity is only a certain activity does not participate, and other activities may have to participate, you must create a separate commodity activity table.

or the classification of goods, a certain number of items of the activities of the participation, you need to establish an activity commodity classification, but it may also be the activities of these classified products to participate in the event, but also to exclude a few special items, or to analyze whether these excluded products have commonalities? If there is commonality, then add the classification label, if the owner is completely personal preference for random removal, then add an exclusion table. This is probably the way of thinking.

  • 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.