Introduction¶
What is a database?¶
definition: A database is a collection of information that exists over a long period of time.
A Database Management System (DBMS) a complex system for managing database interactions.
- Allows users to easily create new databases and specify schema.
- Enables users for search and modify data.
- Stores data intelligently,
- Protects from accidental use
- Allows efficient access, e.g., indexing
- Manages cuncurrent data accesses and modifications.
- Recovers from failures and crashes.
Relational Databases¶
A database system should present the user with a view of the data organized as tables (or relations).
So Relations
are represented as Tables
, column headers are attribute names. Each row is a tuple.
Access with Structured Query Language (SQL).
e.g.¶
Given the database
accountNo |
balance |
type |
---|---|---|
12345 | 1000.00 | savings |
67890 | 2846.92 | checking |
… | … | … |
- What’s the balance of account “67890”?
SELECT balance FROM Accounts WHERE accountNo = 67890;
- Which are the savings accounts with negative balances?
SELECT accountNo FROM Accounts WHERE type = ‘savings’ AND balance < 0;