質問

First of all, I am a beginner in database area. I'm trying to translate my ER diagram to a database schema. I have a table called research paper and a relationship called citation which references to research paper again. One research paper may have references to many other research papers. Let's say a paper with id=1 citates papers with id=2,3,4,5. How can I accomplish this?

役に立ちましたか?

解決

You would accomplish this by creating a junction table (http://en.wikipedia.org/wiki/Many-to-many_(data_model))

In systems analysis, a many-to-many relationship is a type of cardinality that refers to the relationship between two entities (see also entity–relationship model) A and B in which A may contain a parent row[clarify] for which there are many children[clarify] in B and vice versa. For instance, think of A as Authors, and B as Books. An Author can write several Books, and a Book can be written by several Authors. Because most database management systems only support one-to-many relationships, it is necessary to implement such relationships physically via a third junction table (also called cross-reference table),

In this case, since both sides point back to the same table, you'll want to make sure you name the two columns properly so that you can tell which is the research paper, and which are the citations for that paper.

Here's an article with a better representation of the tables (but not as good of an explanation): http://en.wikipedia.org/wiki/Junction_table

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top