Some basics..
Knowing the differing musical modes will aid a great deal too.
There are basically 7 different modes. The order going like this : Ionian, Dorian, Phrygian, Lydian, Mixolydian, Aeolian and Locrian. Ionian is actually your major scale and Aeolian is your minor scale.
So say if i want to construct a bass solo in the key of C ( for simplicity's sake). The Key of C has the notes C, D, E, F, G, A, B. I can obviously stay in the region of the C maj scale, but I can also utilise the other modal scales. I could use D Dorian, E Phrygian, F Lydian, G Mixolydian...and so on so forth. Get the pattern? If you played all the scales i mentioned above, you would also notice that all these scales contain the notes of the C major scale...as they essentially are the 'same' scales but starting from different notes of the C major scale.
Another example.. For a solo in the key of G. The G maj scale contains the notes G,A,B,C,D,E,F#. Simillarly, one could use G Ionina, A Dorian, B Phrygian..so on so forth.
You can find the shapes online OR you could try to figure them out yourself..coming up with your own shapes. The latter approach would be more beneficial as you utilise your brain more! You'll start to notice many different patterns connecting scales.
This is just one among the many theories there are, that are related to music. Chord construction being another important tool..
Chord Construction Crash Course
A normal maj chord is made up of three notes...1 , 3 and 5. First, third and Fifth. The C major chord is derived from the C major scale.. C,D,E,F,G,A,B, so if you LITERALLY take the 1st, third and fifth. You'll get C, E, and G, Which are the notes that make up the C major scale. A minor chord on the other hand is made up of three notes..the difference being the third is flattened.. so you have 1, b3, 5. If you were apply this formula to the C maj scale...you would end up with C, Eb and G. Which is your Cm chord.
You can apply this to almost any other chords.. Knowing this would let you understand the rudimentary knowledge of chord construction. Henceforth, allowing you to understand other types of chord construction..which are extremely similar in nature.
This sort of theory is universal, e.g. can be applied to any other musical instruments. Know this and you would be one tiny step closer to being a bass virtuoso