Definition of the Building_FreeUnits table. When the Building is completed by whatever means, the specified unit is given. The same building can have multiple different units listed in the table, and will give all such units upon completion of the building.
Code:
<Table name="Building_FreeUnits">
<Column name="BuildingType" type="text" reference="Buildings(Type)"/>
<Column name="UnitType" type="text" reference="Units(Type)"/>
<Column name="NumUnits" type="integer"/>
</Table>
Columns "FreeUnit" and "FreeUnitPrereqTech" in table "Traits" can also be used but they are one-shot deals.
The best method to determine what can and cannot be done by xml or sql methods is to look at the game's base xml files. Even though the game uses an SQL database, Firaxis uses xml files to build the contents of the unmodded game database.
Mods can then alter the contents of that unmodded database using either xml or sql.