![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi everybody, I'm a designer with some basic database knowledge but I would like some suggestions on a database design problem that's really too much for me.. Here's the question: I need to build some kind of a bibliographical database for storing: People, Books, Conferences, Groups (universities, research groups,...), Projects I also want to be able to store any _arbitrary_ relationship between any of them (many to many) for example: - People may: write/edit/publish/... books partecipate/direct/organize/... conferences be part of/direct/... groups partecipate/guide/write about/... projects - Books may: cite/review/.. other books be proceedings of/be presented at/... conferences ... You get the idea. Any entity can have an arbitrary relationship (user entered, not hard coded) with any other entity. Now, for the solution I considered either making a mess with a thousand many to many relationship tables: table book_book (idRelationship, idBook1, idBook2, relationship_type) But it makes everything really complicated and hard (for me) to query.. Or, a thing I made up myself that I suppose is something a database designer would abhor: some kind of superfreedom-many-to-many: table relationship (idRelationship, id1, type1, id2, type2, relationship_type) for example: 23, person-> 15, book, (author) I suppose I'm not the first one trying to use a db to store a network structure.. do you have any suggestions or reference? It doesn't need to be super-fast or super-scalable, but it does need to make sense.. The final aim is mainly to navigate and visualize relationships and graph. Hope you can help me. Thank you, Marco |
#3
| |||
| |||
|
|
Marco, This is one way to accomplish what you want. EntityType table ------ EntityTypeID PK EntityTypeName Entity table ------ EntityID PK EntityTypeID FK to EntityType table EntityName AffiliateType table ------ AffiliateType PK AffiliateTypeName EntityAffiliatedWithEntity table ------ EntityID PK, FK to Entity table AffiliateEntityID PK, FK to Entity table AffiliateTypeID FK to AffiliateType table. EntityTypeName could be Person, Book, Conference, etc. AffiliateTypeName could be "Writes", "Edits", "Publishes", etc. -- Bill "Marco Q." <mar... (AT) gmail (DOT) com> wrote in message news:1170428808.345592.236720 (AT) s48g2000cws (DOT) googlegroups.com... Hi everybody, I'm a designer with some basic database knowledge but I would like some suggestions on a database design problem that's really too much for me.. Here's the question: I need to build some kind of a bibliographical database for storing: People, Books, Conferences, Groups (universities, research groups,...), Projects I also want to be able to store any _arbitrary_ relationship between any of them (many to many) for example: - People may: write/edit/publish/... books partecipate/direct/organize/... conferences be part of/direct/... groups partecipate/guide/write about/... projects - Books may: cite/review/.. other books be proceedings of/be presented at/... conferences ... You get the idea. Any entity can have an arbitrary relationship (user entered, not hard coded) with any other entity. Now, for the solution I considered either making a mess with a thousand many to many relationship tables: table book_book (idRelationship, idBook1, idBook2, relationship_type) But it makes everything really complicated and hard (for me) to query.. Or, a thing I made up myself that I suppose is something a database designer would abhor: some kind of superfreedom-many-to-many: table relationship (idRelationship, id1, type1, id2, type2, relationship_type) for example: 23, person-> 15, book, (author) I suppose I'm not the first one trying to use a db to store a network structure.. do you have any suggestions or reference? It doesn't need to be super-fast or super-scalable, but it does need to make sense.. The final aim is mainly to navigate and visualize relationships and graph. Hope you can help me. Thank you, Marco |
#4
| ||||||
| ||||||
|
|
Hi everybody, I'm a designer with some basic database knowledge but I would like some suggestions on a database design problem that's really too much for me.. Here's the question: I need to build some kind of a bibliographical database for storing: People, Books, Conferences, Groups (universities, research groups,...), Projects |
|
I also want to be able to store any _arbitrary_ relationship between any of them (many to many) for example: - People may: write/edit/publish/... books partecipate/direct/organize/... conferences be part of/direct/... groups partecipate/guide/write about/... projects - Books may: cite/review/.. other books be proceedings of/be presented at/... conferences ... |
|
You get the idea. Any entity can have an arbitrary relationship (user entered, not hard coded) with any other entity. |
|
Now, for the solution I considered either making a mess with a thousand many to many relationship tables: table book_book (idRelationship, idBook1, idBook2, relationship_type) But it makes everything really complicated and hard (for me) to query.. |
|
Or, a thing I made up myself that I suppose is something a database designer would abhor: some kind of superfreedom-many-to-many: table relationship (idRelationship, id1, type1, id2, type2, relationship_type) for example: 23, person-> 15, book, (author) |
|
I suppose I'm not the first one trying to use a db to store a network structure.. do you have any suggestions or reference? It doesn't need to be super-fast or super-scalable, but it does need to make sense.. The final aim is mainly to navigate and visualize relationships and graph. Hope you can help me. Thank you, Marco |
#5
| |||
| |||
|
|
Marco, This is one way to accomplish what you want. EntityType table ------ EntityTypeID PK EntityTypeName Entity table ------ EntityID PK EntityTypeID FK to EntityType table EntityName AffiliateType table ------ AffiliateType PK AffiliateTypeName EntityAffiliatedWithEntity table ------ EntityID PK, FK to Entity table AffiliateEntityID PK, FK to Entity table AffiliateTypeID FK to AffiliateType table. EntityTypeName could be Person, Book, Conference, etc. AffiliateTypeName could be "Writes", "Edits", "Publishes", etc. -- Bill have you been taking DB design lessons from neo? |
#6
| ||||||
| ||||||
|
|
(...) - Books may: cite/review/.. other books be proceedings of/be presented at/... conferences ... You started (but haven't finished) identifying your relationships. Still good. You get the idea. Any entity can have an arbitrary relationship (user entered, not hard coded) with any other entity. Why do you think they are "arbitrary"? |
|
Now, for the solution I considered either making a mess with a thousand many to many relationship tables: table book_book (idRelationship, idBook1, idBook2, relationship_type) But it makes everything really complicated and hard (for me) to query.. Why is it so hard? Consider making views for the major queries you need to make. Then it looks like fewer denormalized tables, when the reality is lots of well normalized tables. |
|
Or, a thing I made up myself that I suppose is something a database designer would abhor: some kind of superfreedom-many-to-many: table relationship (idRelationship, id1, type1, id2, type2, relationship_type) for example: 23, person-> 15, book, (author) Cough. here we go, starting down the EAV path again. |

|
You only have a network structure because you are not thinking about the data properly. Those ID fields start to become network links and you end up using your Relational model DB as a Network model one, only without the tools of the old Network model DB products. (nothing to help repair the IDs that link it all together when it gets out of sync). |
|
There is nothing wrong with a database with many tables. Some of them you might later denormalize for performance. others you might wrap in views. A helpfull iea in deciding on your final design is to consider what queries you might run on the database. |
|
You have started down the golden path. Don't abandon it now. |
#7
| |||
| |||
|
|
On Feb 2, 12:09 pm, "AlterEgo" <altereg... (AT) dslextreme (DOT) com> wrote: Marco, This is one way to accomplish what you want. EntityType table ------ EntityTypeID PK EntityTypeName Entity table ------ EntityID PK EntityTypeID FK to EntityType table EntityName AffiliateType table ------ AffiliateType PK AffiliateTypeName EntityAffiliatedWithEntity table ------ EntityID PK, FK to Entity table AffiliateEntityID PK, FK to Entity table AffiliateTypeID FK to AffiliateType table. EntityTypeName could be Person, Book, Conference, etc. AffiliateTypeName could be "Writes", "Edits", "Publishes", etc. -- Bill have you been taking DB design lessons from neo? this looks like a variation of EAV. Only problem is you left out the Value portion. ed |
#8
| |||
| |||
|
|
On Feb 2, 12:09 pm, "AlterEgo" <altereg... (AT) dslextreme (DOT) com> wrote: Marco, This is one way to accomplish what you want. EntityType table ------ EntityTypeID PK EntityTypeName Entity table ------ EntityID PK EntityTypeID FK to EntityType table EntityName AffiliateType table ------ AffiliateType PK AffiliateTypeName EntityAffiliatedWithEntity table ------ EntityID PK, FK to Entity table AffiliateEntityID PK, FK to Entity table AffiliateTypeID FK to AffiliateType table. EntityTypeName could be Person, Book, Conference, etc. AffiliateTypeName could be "Writes", "Edits", "Publishes", etc. -- Bill have you been taking DB design lessons from neo? this looks like a variation of EAV. Only problem is you left out the Value portion. ed |
#9
| |||
| |||
|
|
"Ed Prochak" <edproc... (AT) gmail (DOT) com> wrote in message news:1170439341.306920.144360 (AT) k78g2000cwa (DOT) googlegroups.com... On Feb 2, 12:09 pm, "AlterEgo" <altereg... (AT) dslextreme (DOT) com> wrote: Marco, This is one way to accomplish what you want. EntityType table ------ EntityTypeID PK EntityTypeName Entity table ------ EntityID PK EntityTypeID FK to EntityType table EntityName AffiliateType table ------ AffiliateType PK AffiliateTypeName EntityAffiliatedWithEntity table ------ EntityID PK, FK to Entity table AffiliateEntityID PK, FK to Entity table AffiliateTypeID FK to AffiliateType table. EntityTypeName could be Person, Book, Conference, etc. AffiliateTypeName could be "Writes", "Edits", "Publishes", etc. -- Bill have you been taking DB design lessons from neo? this looks like a variation of EAV. Only problem is you left out the Value portion. ed Ed: PMFJI. The OP is a classic question on how to design a database. The same question gets asked over and over again in every database forum. The subject matter varies from bibliographies to software libraries to parts lists to cataloguing the genome. But it's really the same question, if you can recognize it as such. The generic question is: I want my users to be able to discover and record new data relationships, using only DML. I want the system to be able to react to these new discoveries as if the new data relationships had been recorded using DDL. I don't want my users doing DDL, but I need a database structure that will be invariant to the discovery of new data relationships. What that means is that (some of) what looks like data to the DBMS is really metadata. And the DBMS metadata is really what: meta-metadata? EAV is a classic solution to this conundrum. It has a whole lot of defects, which I'm sure I don't need to tell you about. But almost every discussion of meta-metadata will inevitably be drawn to a discussion of EAV.- Hide quoted text - - Show quoted text - |
#10
| |||
| |||
|
|
The final aim is mainly to navigate and visualize relationships and graph. |
|
Here's the question: I need to build some kind of a bibliographical database for storing: I also want to be able to store any _arbitrary_ relationship between any of them (many to many) for example: |
![]() |
| Thread Tools | |
| Display Modes | |
| |