Lets analyze the sentence. The first three words are easy:
Er
This is a personal pronoun in nominative case. Nothing else in this sentence is in nominative case, so this must be the subject, and because the sentence is not in passive voice, but in active voice, its also the agent, i.e. the person or thing that actively performs the action that is described in the sentence.
gab
This is an inflected verb. It is on position 2, where an inflected verb must be in a German sentence that is a statement. It is a form of »geben« (to give). The form »gab« could be 1st or 3rd person, but because the subject is 3rd person, it's 3rd person here. Other grammatical properties of this form of »geben« are:
- Singular (not Plural. This is because the subject (»er«) is singular.)
- Indikativ (not Imperativ or Konjunktiv. This sentence is a statement. It's not a command and it does not describe something fictional.)
- Präteritum This is the grammatical tense. It is one of the German past tenses.
- Aktiv It's active voice, not passive voice.
ihr
This is again a personal pronoun, but this is in dative case. So it can't be the subject. It must be an object.
The verb »geben« almost always comes together with an object that names the receiver of the gift. And this receiver must be in dative case. (In fact the name »dative« comes from the latin verb »dare« (do, das, dare, deti, datum) which means: to give, so »dative« means: The give-case)
And so, the personal pronoun »ihr« is just this dative object that names the receiver of the gift.
Now we know, that a male person gave something to a female person. And when something is given, it is very interesting what is given. What is the gift? And this is why the verb geben always needs an object that names the gift. This object is mandatory, and it is in accusative case. So, when the verb of the sentence is a form of »geben«, you need a giver (the subject), you need the receiver (the dative object) and you need the gift which is an accusative object.
So, let's search for a noun or a pronoun that is in accusative case:
Flaschen
Lets make a test with a verb that always needs an accusative object like »haben« (to have):
Ich habe Flaschen.
Yes, that works, so Flaschen is a hot candidate for being the accusative object of our verb »gab«
Parfums
Test it:
Ich habe Parfums.
Works too, so we put it on the list.
Geburtstag
Ich habe Geburtstag.
We can put this on our list too.
So, all three nouns could be in accusative case, but the last one does not make sense as a gift. (You can not give a birthday to someone.) In fact only one of them is really in accusative case, but we will see that later.
So, bottles (Flaschen) and fragrance (Parfum) could be the gift. But these are not two separate gifts. The gift is two bottles of fragrance. So, here we have the full accusative object:
- zwei klein__ Flaschen teur__ französisch__ Parfums
This is the accusative object, and this is the gift. Let's split it in smaller parts:
zwei klein__ Flaschen
If we ignore the adjective for a moment, this looks some kind of unit like »5 feet«, »3 gallons« or »a spoonful«. And this is the case here: How much fragrance did he give? - He gave two bottles of fragrance.
And grammatically this is the main part of the gift. This is the part in accusative case. And the form of »klein«, which is an attribute of »Flaschen« must therefore also be in accusative case. So, let's collect the properties that this attribute must have:
- case: accusative (because it's an attribute of a noun in accusative case)
- number: plural (because we have not one, but two bottles)
- gender: doesn't matter, because we are in plural
- comparison: positive (it's not comparative and not superlative)
- definiteness: strong declination because there is no article-word and therefore the adjective itself must carry the case-ending
If you have all this together, you can look up in a declension table like this one: declension of the adjective klein. The order of properties in this table is this: first find the block with the right comparison. We need »positiv«, so it's the first block. Then we need the definiteness to find the right section which is »Starke Deklination« (strong declension). Then we need number and gender to find the right column and the grammatical case tells us the line, and so we find:
kleine
zwei kleine Flaschen
teur__ französisch__ Parfums
So, what is this? He gave her two small bottles of expensive french fragrance. In English you use the word »of« to mark this part of speech which grammatically an attribute of »two small bottles«. But in German we have grammatical cases that can do the job.
The part »teur__ französisch__ Parfums« is a genitive attribute of »zwei kleine Flaschen«, so it's in genitive case, and now we now know, that the word »Parfums« is not in accusative case, but in genitive case. And this genitive attribute is a nominal group that consists of the noun »Parfums« which has two adjectives as attributes. And again we have no article word. So we have here:
- case: genitive
- number: singular (two bottles, but still just one fragrance)
- gender: neuter (becausee the word »das Parfum« is neuter)
- comparison: positive (it's not comparative and not superlative)
- definiteness: strong declination because there is no article-word
The declension tables of teuer and französisch tell us for these combinations:
teuren, französischen
teuren, französischen Parfums
So, the whole accusative object is this:
zwei kleine Flaschen teuren französischen Parfums
But there is still something left:
zum vierzigst__ Geburtstag
The word »zum« is a contraction of the preposition »zu« and the article »dem«. So, we can write this part of speech also in it's extended form:
zu dem vierzigsten Geburtstag
This is an optional prepositional object. A prepositional object begins with a preposition, and then this preposition needs an inner object in a case, that no longer depends on the verb of the sentence, but on the preposition itself. The preposition »zu« always needs its inner object to be in dative case, so »dem vierzigsten Geburtstag« must be in dative case, what you also can see from the article »dem« which exists in this form only in dative case. So, here we have this combination:
- case: dative
- number: singular (only one birthday)
- gender: masculine (because the word »der Geburtstag« is masculine)
- comparison: positive (it's not comparative and not superlative)
- definiteness: weak declination because we have a definite article (»dem« which is contained in »zum«)
The declension table for vierzigste says:
vierzigsten
zum vierzigsten Geburtstag
And when we put all together, we finally have:
Er gab ihr zwei kleine Flaschen teuren französischen Parfums zum vierzigsten Geburtstag.