What is the relationship between the focal length and f number of a telescope compared to a guide scope? How do you determine the optimal length of a guide scope for a given imaging telescope?

I imagine it would have to take into consideration the pixel size of the guide scope, but would the aperture matter as well?
The aperture of the guide scope matters because it affects how faint the stars are which are available for guiding - the larger the aperture the fainter the stars it will pick up which gives you more choice when picking a good one as a guide star. This is especially important if you are imaging from an urban area where light pollution may otherwise limit the number of visible stars. 
The length of the guide scope is not directly important, although generally larger diameter objective means longer anyway. The weight of the guide scope does however have to be also considered as your mount has to be able to deal with the extra load you are placing on it, lighter is better here of course.
When you talk about pixel size I presume you mean pixel size of the CCD camera you are attaching to the guide scope itself? I am not expert enough to go into great details there, if you need more in depth advice on that side of astrophotography I can thoroughly recommend the Cloudy Nights forum, there are some very experienced astrophotographers on there who are very willing to share their knowledge and experience with all no matter how much of a beginner you may be.