When you are playing with other musicians, the most important thing is to listen to each other and try to respond to what the other players are doing. In an ideal band, everyone is equally responsible for keeping good time but in reality, many musicians (especially guitarists who play by ear only) neglect the study of rhythm and beat subdivisions and rely on the rhythm section to keep good time and indicate what is happening rhythmically. While a singer or horn player has time to breathe between phrases and a guitarist or keyboard player leaves space between lines or chords, the drummer and bass player have to play consistently to keep the groove going and feeling good.
Because the bass and drums work so closely together, it is worth learning a bit about drum notation and drumming in general. Drum music is usually written in the spaces of the percussion staff, including the space above the staff, to represent different parts of the drum kit. The most commonly used system is shown here. Notice that cymbals are notated with an X in a similar manner to ghost notes on the bass.
The following example demonstrates a simple Rock beat on the drums. Read the next example and imagine the sounds of the drums as you follow the notes.
If you were going to create a bass line to go with this drum beat, the first thing you would look at is the bass drum pattern. Because of the type of patterns the bass drum plays, as well as its low sound, the bass and bass drum often "lock in" together as shown in the following example.
Another common point where the bass and drums often connect is where the snare drum is played. Notice that the bass plays along with some of the snare drum notes but not all of them.
If you wanted to change the bass line to make it sound more interesting, there are a couple of things you could look for in the drum part which might give you some ideas. The first is the open hi-hat on the "and of 4" in the first bar. This would be a good spot to put an extra bass note, because it adds interest to the line and also connects directly with the drums. The other clue here is that the hi-hat part consists of constant eighth notes, which means you could put extra notes on any of these eight points in the bar, or in between them so that the hi-hat answers the bass.
As previously mentioned, it sometimes works well to have the bass play in between some of the drum parts and let the drums (e.g., snare drum) answer the bass. This also works the other way around, i.e., the bass answers the drums.
If you work together often with a drummer, you can get to the point where you each know what the other is going to do next and orchestrate the music between you as you play. When you get to this point, the bass and drums begin to sound like different parts of one multi-faceted instrument. This is the goal all rhythm section players should aim for.