Wednesday, 15 January 2014

python - Database designed correctly -



python - Database designed correctly -

i creating django project has dentists. each client has own set of teeth have model client , model tooth foreignkey customer

there exam called periodontogram stores info each tooth ginginal margin probing depth if has implant (the tooth ) etc. want implement on project. considering client might have more 1 periodontograms decided implement model. , each periodontogram model has many periodontogram operations each 1 of them consists info each tooth. looks this

class customer(models.model): ..... class tooth(models.model): client = models.foreignkey(customer) class periodontogram(models.model): client = models.foreignkey(customer) date = models.datefield() class perioperation(models.model): tooth = models.foreignkey(tooth) peri = models.foreignkey(periodontogram) #rest of work done per tooth implant = models.booleanfield() ginginal_margin1 = models.integerfield() #...more

frontend sends json info on backend save it. in order save must

create new periodontogram , save db create operation per tooth (got frontend) assign peri field perioperation periodontogram created in step 1

but happens if of operations fail when creating operation per tooth. peri saved not operations. best way deal it?

you should utilize database transaction info saved db or nil saved. can read more transactions here

https://docs.djangoproject.com/en/dev/topics/db/transactions/

you may have check how mysql handling transactions:

http://dev.mysql.com/doc/refman/5.0/en/commit.html

python mysql django

No comments:

Post a Comment