sql - Circular database relationships. Good, Bad, Exceptions? -
I have stopped developing this part of my app for a while because I want to do it in a circular way I want to remind my lecturers, who is telling me in school.
I have a design for an order system, which is not related to this example which I am leaving:
- Customer
- Order
I would like that,
<Basically the last part is that where the problem arises, sometimes the credit card is declined And they want to use someone else, it needs to be updated, which is their 'current' card, but see it
effectively creates a circular design between these three tables is.
Possible solutions: either
create circular design, reference:
- CC rif for order,
- CC
- Refers to all three table IDs and puts unique on the order so that only one CC is run in this sequence at any time.
Essentially, both models translate in the same design but differently, I prefer this option as the best option later because it looks less circular and more central.
My questions are,
- What if everyone is the pros and cons of each?
- What is the loss
- Is there a valid exception for this rule?
- Should I choose some for some reasons?
Thank you and tell me if you have any explanation / explanation.
- Update / edit -
I have seen an error in those requirements that I said. While trying to simplify things for the SO, basically dropped the ball. There is another table for payment, which adds another layer, with the possibility of using different credit cards, there may be several payments in order. (If you really want to know other forms of payment)
Here it is because because I think the underlying issue is still the same and it only adds another layer of complexity.
A customer may have 0 or more credit cards attached, but the association is dynamic - it comes And as you can tell that a credit card can be associated with more than one customer, it ends with a n: m table, perhaps with a flag column for "active" .
An order has a steady relationship with 0 or 1 credit card, and after completion of a sale, there is no mess with the CC value, the relationship between the CC and the customer does not matter . The order table should be stored independently of all related information about the CC at the time of sale. There is no reason to associate the sale with any other credit card column in any other table (which can change - but this will not affect sales).
Comments
Post a Comment