Ok, I'm totally new in this music making thing and these questions maybe stupid, but I'm asking it still, because I can't quite figure it out myself. (yes, I'm stupid

) How do you write your stuff to make them stay in note? And if I make my own loop, are there any rules, how I determine which is the main note (or what ever the real term is)?
I'm not asking to give long tutorials etc.., just basics shortly.
Help would be appreciated. Thanks!
WiErDmAsTer