Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

If you have a character_instance and character entity in an ERD for a video game, and you want to indicate that something happens when a character entity encounters a character_instance entity, how do you do that? Here's the catch, though: a character_instance doesn't have the same relationship to its own character. Is there any special way to indicate this complicated relationship?

share|improve this question
    
I'm not sure I follow. Substituting another data type, you seem to be saying, "indicate that something happens when a variable of type INTEGER encounters a value of type INTEGER" (and I'm tempted to reply, we call this 'assignment' :) –  onedaywhen Jan 31 '12 at 9:10
    
@onedaywhen It wouldn't be able to encounter itself, though. When 1 encounters any integer but 1, for example. –  Wolfpack'08 Feb 2 '12 at 12:02
add comment

1 Answer

up vote 1 down vote accepted

I don't know about ERD but, if I have understood correctly, this kind of business rule is very common when considering relationships between entities e.g. consider this example in SQL:

CREATE TABLE People 
(
 person_ID VARCHAR(20) NOT NULL UNIQUE
);

CREATE TABLE Marriages
(
 spouse_1 NOT NULL UNIQUE REFERENCES People (person_ID), 
 spouse_2 NOT NULL UNIQUE REFERENCES People (person_ID), 
 CHECK (spouse_1 < spouse_2)
);

In addition to enforcing the rule that a person cannot marry themselves, it also ensures that the same marriage is not entered a second time 'in the other direction' i.e. 'Albert is married to Victoria' is the same as 'Victoria is married to Albert' but only the row `('Albert', 'Victoria') may be entered into the database.

If this is too complex for ERD, consider using another more expressive model e.g. object role modelling.

share|improve this answer
    
I think this is a good explanation. I saw a way to represent it. Have [user] connect to <friendship>, and then <friendship> connects back to [user]. –  Wolfpack'08 Feb 3 '12 at 7:00
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.