The idiom "Don't shit/defecate where you eat" means:
One should not cause trouble in a place, group, or situation in which one regularly finds oneself.
[Wiktionary]
I always understood what it literally means is you should not make a trouble in a place you regard as the most important place in your life.
If you watch this clip of the Big Bang Theory, it sounds like I don't understand the meaning of the idiom 100%.
Questions:
When did this idiom become popular? The word used in the idiom is not pleasant and I wonder when and how people started to use this idiom. (I believe its equivalent is used in Asia)
Is there any better replacement for it when you don't want to use the word "shit/defecate"?
Is Amy (the female) telling the truth or is it just a joke when she said "don't have a romantic relationship in the workplace." I don't see a strong correlation between the idiom and the romantic relationship in the workplace.