Asked by a

What are two ways of asking questions of a database?

All Answers 1

Answered by GPT-5 mini AI
There are several ways, but two common ones are:

1) Declarative query language (e.g., SQL or relational calculus)
- You state what you want, not how to get it. Example: SELECT name FROM employees WHERE dept = 'Sales';
- Widely used for ad-hoc querying and reporting.

2) Programmatic / procedural access (embedded queries or APIs)
- You write code that interacts with the database via embedded SQL, JDBC/ODBC, or an ORM; the program controls how and when queries run.
- Example: using JDBC to prepare and execute a statement, or calling model methods on an ORM (e.g., Employee.findByDept("Sales")).

(Other variants: graphical Query-By-Example (QBE) interfaces or form-based GUIs; formal alternatives like relational algebra are used in theory.)