You're right, Bitcoin doesn't natively have a way to query a database, but here's an example of a how to read Blockcast transactions from the blockchain:
The next step would be storing the results in a SQL database as we do with our production servers that maintain a queryable database of Open Publish registrations and transactions (Open Publish uses Blockcast for storing metadata on digital media assets).
This is definitely a more piecemeal approach to creating smart contract applications than with Ethereum's one-stop-shop, but there are benefits to building on top of Bitcoin, especially for Open Publish, which uses native Bitcoin transactions for payments and royalties.
Bitcoin doesnt make the data queryable in any way. You need to know the transactions where the data is stored ahead of time.
With Ethereum, you can create a "contract" that emits "events" which automatically get added to a queryable database.