Re: many junction tables
От | Martijn van Oosterhout |
---|---|
Тема | Re: many junction tables |
Дата | |
Msg-id | 20010905200616.B7308@svana.org обсуждение исходный текст |
Ответ на | Re: many junction tables (E Kolve <ekolve@corp.classmates.com>) |
Список | pgsql-general |
On Tue, Sep 04, 2001 at 10:22:19AM -0700, E Kolve wrote: > The idea is this. Suppose I had say 40 or 50 tables like city or > company (schools, purchases, etc) where I want to have a one to many > relationship (One person can purchase many things, one person can attend > many schools) I would have to create many junction tables > (school_persons, purchase_persons, etc). What I am looking for is a > solution to creating all these tables, if at all possible. Well, for one-to-many relationships you don't need separate tables. Only many-to-many relationships need that. And most of the time a many-to-many relationship needs more than just the two fields. For example, students and classes have a many-to-many relationship, but just a simple two column table is not enough, what you really need it a new enrolment table which has the two fields and also any other information related (like grades, etc). Since you only create the schema once, you can just generate a script to create them for you. Yes, you'll get a lot of tables, but it's a complex data structure. So in the end all you have is one-many relationships. -- Martijn van Oosterhout <kleptog@svana.org> http://svana.org/kleptog/ > Magnetism, electricity and motion are like a three-for-two special offer: > if you have two of them, the third one comes free.
В списке pgsql-general по дате отправления: