Hi all,
Just a short question concerning database design in general and
SQLAlchemy in particular. Let's take the many-to-many example from the
docs (chapter Data Mapping), where we have a table containing articles
and one containing some keywords. Now, I understand the normal layout of
such a many-to-many relationship: Create 2 separate tables (in this case
"articles " and "keywords") and create the relationship link using a 3rd
table ("articlekeywords_table").
I was wondering: In this special case, where one end of the relationship
consists of very "small" objects - essentially, each keyword object is
not more than a string - why shouldn't I simply use a one-to-many
structure like this:
articles_table = Table('articles', metadata,
Column('article_id', Integer, primary_key = True),
Column('headline', String(150), key='headline'),
Column('body', TEXT, key='body'),
)
my_keywords_table = Table('article_keywords', metadata,
Column('article_id', Integer, ForeignKey("articles.article_id")),
Column('keyword_string', String(50))
)
I am aware that this is not a db-layout which is normalized like the
theory says you should, but in this special case where the second end of
the relationship only consists of single strings... why not? What is the
advantage of the "classic" many-to-many way of doing it?
Probably, I am missing something, so I would appreciate if someone could
tell me the flaw in my thinking.
Thanks and Cheers,
Martin
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Sqlalchemy-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users