Hi Mike,

thanks a lot for your help.

I know the concepts of db-normalization and 3NF - but haven't worked so
much with that in practice. One of my problems is that I think the
object-orientated way. I started quite early to work with OODBMS
instead of RDBMS.
I an OODBMS SetSet would just a list/array inside of TrainingUnit. I
wouldn't need to take care about relation tables or object ids - the
OODBMS make this for me.

But at this project I have no choice - I need an RDBMS.

On 2015-09-29 12:04 Mike Bayer <mike...@zzzcomputing.com> wrote:
> >      sqlite> SELECT a_oid, b_oid FROM a_b_relation;
> >      1|1
> >      1|1
> >
> > You see here that `a` has two references to the same entity/row `b`.
> > In my data structure this make sense. But maybe it break a
> > SQL-/RDBMS-rule?
> it does, it breaks first normal form in that there is no primary key 
> (http://www.tutorialspoint.com/sql/first-normal-form.htm).

But does a relation-table need a primary key? For me a relational-table
is just a helper-table (or a workaround) because RDBMS doesn't support
"native" 1-to-n or m-to-n references.
The normal-form-rules does have to fit to all(!) tables including
relation-tables?

> OK but those are not the same SetSet, they happened at two different 
> times.   They should be separate entities of data.

I understand what you mean. But the data in SetSet haven't a
time-dimension. The time (as a date) is coded in the TrainingUnit.
There is a attribute/row fort that.

> would like SetSet objects to be unique on their reps/weight, then the 
> association table itself would become an entity in which case you'd
> need to add an additional column to it as a primary key.

I am not really getting into that. Everytime i try to rearange my
current structure I ran into the same problem.

This is the real (little bit snipped) structure, where I can not see
how this would help me, when I add a primary-key to
the table named 'tu_set_relation'.


tu_set_relation = sa.Table('tu_set_relation', _Base.metadata,
    sa.Column('tu_oid', sa.Integer, sa.ForeignKey('TrainingUnit.oid')),
    sa.Column('set_oid', sa.Integer, sa.ForeignKey('SetSet.oid'))
)


class TrainingUnit(_Base):
    __tablename__ = 'TrainingUnit'

    _oid = sa.Column('oid', sa.Integer, primary_key=True)
    _date = sa.Column('date', sa.Date)
    _sets = sao.relationship('SetSet', secondary=tu_set_relation),
    _machine_fk = sa.Column('machine', sa.Integer,
    sa.ForeignKey('Machine.oid')) _machine = sao.relationship("Machine")


class SetSet(_Base):
    __tablename__ = 'SetSet'    # 'Set' is a reserved word in SQL

    _oid = sa.Column('oid', sa.Integer, primary_key=True)
    _repetitions = sa.Column('repetitions', sa.Integer)
    _level = sa.Column('level', sa.Integer)
-- 
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1

mQENBFQIluABCACfPwAhRAwFD3NXgv5CtVUGSiqdfJGVViVBqaKd+14E0pASA0MU
G0Ewj7O7cGy/ZIoiZ0+lIEZmzJKHfuGwYhXjR/PhnUDrQIHLBvh9WuD6JQuULXfH
kXtVm/i9wm76QAcvr2pwYgNzhcJntUHl2GcgnInYbZDeVmg+p9yIPJjuq73/lRS3
0/McgNoFOBhKK/S6STQuFyjr9OyJyYd1shoM3hmy+kg0HYm6OgQBJNg92WV9jwGe
GzlipvEp2jpLwVsTxYir2oOPhfd9D1fC9F/l/3gXbfjd5GIIVrZFq2haZmoVeJ33
LJxo3RA5Tf9LoUeels1b4s9kFz6h7+AHERUpABEBAAG0IUNocmlzdGlhbiBCdWh0
eiA8YnVodHpAcG9zdGVvLmRlPokBPgQTAQIAKAUCVAiW4AIbAwUJAeEzgAYLCQgH
AwIGFQgCCQoLBBYCAwECHgECF4AACgkQZLsXsAdRqOxNUAf/V/hDA5zGDpySuCEj
DhjiVRK74J9Wd8gfH0WAf1Co5HZ24wZH8rgOIVIgXw8rWkOw/VA6xfdfT+64xjTY
Fhkpbrk199nDzp72F7Jc4NC+x8xac2e3rK5ifSWhZx7L5A32pGYE+d16m3EEqImK
D4gcZl38x9zdUnD4hHyXkIPz1uCfuMuGgWEnaUk4Wbj41CBZr3O0ABue6regV15U
jaes8r+B8iCcY+0yP2kse+3iaCaMqNv5FgQZ9+b2Cql8pFkZJVtBVUw4GW3DWZJi
du0O/YrC9TgS+xY9ht/MD2qSHwjcK1sdImjqBO7xP8TIOwKeYyDvGKnSO3EJ/sSA
UPGEPrkBDQRUCJbgAQgA0k/Qg67CCUJE2/zuxBEoK4wLJpDRJzh8CQPZpjWx8VP0
KL892jwfxymXn8KNhuy1SgCBFSeV9jg4VZNWDlUGJc2lo82ajr9PzIsrQwu4lf0B
zrUWV5hWepKu/kb8uSjx58YYfx0SFz4+9akX3Wwu9TUHntzL5Gk3Q26nnsr1xEJ+
VEumvCH9AE0Tk0K7dQpJ2/JcLuO+uhrpd/lHFDYVN5NsG3P015uFOkDI6N/xNFCj
v95XNR93QlfKpK3qWlFGescfG+o/7Ub6s67/i/JoNbw0XgPEHmQfXpD7IHO4cu+p
+ETb11cz+1mmi96cy98ID+uTiToJ8G//yD9rmtyxoQARAQABiQElBBgBAgAPBQJU
CJbgAhsMBQkB4TOAAAoJEGS7F7AHUajs6sQH/iKs6sPc0vkRJLfbwrijZeecwCWF
blo/jzIQ8jPykAj9SLjV20Xwqg3XcJyko8ZU6/zuRJq9xjlv9pZr/oVudQAt6v+h
2Cf4rKEjmau483wjMV2xjTXQhZi9+ttDbia4fgdmGtKsOicn5ae2fFXcXNPu3RiW
sZKifWdokA6xqMW6iIG9YjjI5ShxngHWp2xfPscBFMDRtFOMags/Yx+YvwoyEZ4A
dURYMFHFqpwILEc8hIzhRg1gq40AHbOaEdczS1Rr3T7/gS6eBs4u6HuY5g2Bierm
lLjpspFPjMXwJAa/XLOBjMF2vsHPrZNcouNKkumQ36yq/Pm6DFXAseQDxOk=
=PGP9
-----END PGP PUBLIC KEY BLOCK-----

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to