Friday, November 29, 2013

Re: multi-table inheritance newbie

On Fri, 29 Nov 2013 07:34:47 -0800 (PST), TW <terry433iid@googlemail.com>
declaimed the following:

>I'm using multi-table inheritance in project and need some help geeting my
>mind around this concept
>
>I have parent class 'test' which is a machine test (members : name, version
>state; methods : add_test, remove_test)
>
>I now create a child class 'result' which inherits from parent class 'test'
>- 'result' is the result of all the scenarios inside the machine test
>(multiple scenarios per machine test)
>
>Child class 'result' will have its own members/methods (members :
>scenario_name, scenario_outsome; methods : add_result, delete_result)
>
>So now I can create an instance of parent 'test' class by calling the child
>class 'result'
> >>>>testme= result.add_test("""args""")
>
>So what is now in the object "testme" that I just created? I cannot
>viasualise what this instance holds and how the parent/child relationship
>works
>
>What would be some useful method calls be to help me get a better
>understanding of the 'result' object so I could 'see' the influence of the
>'parent' class inheritance
>
>thanks


Normally I'd trim the quote, but there are too many concepts floating
around in the above...

My first impression is that you are using the wrong mechanism... You
probably want a one-to-many relationship between two otherwise independent
tables:

TEST(_ID_, name, version, state)
RESULT(_ID_, *testID*, name, outcome)

in which _ID_ is the table primary key (Django handles those behind the
scenes as I recall), and *testID* is a foreign key linking that RESULT row
to the corresponding TEST description. Multiple "scenarios" in one "test"
means multiple RESULT rows all having the same testID value.

Inheritance, as normally considered in OOAD, implies an extension from
the base class...

VEHICLE(_ID_, maker, model, serialnumber)
CAR[VEHICLE](engine, transmission, tiresize, exteriorcolor, interiorcolor,
audio)
JETLINER[VEHICLE](engine, firstclassSeats, businessclassSeats, coachSeats)

Both CAR and JETLINER inherit _ID_, maker, model, serialnumber from
VEHICLE.

https://docs.djangoproject.com/en/1.4/topics/db/examples/many_to_one/

instead of

https://docs.djangoproject.com/en/1.4/topics/db/models/#model-inheritance

--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/k5hh99lf7341nauigebit43pe4qfjl5jfm%404ax.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment