Concepts#
- Data: raw facts; information: processed data. Database: organised collection of data. DBMS: software to create and manage databases (LibreOffice Base, MySQL, Oracle, MS Access).
- Advantages: less redundancy and inconsistency, data sharing, security, integrity, backup.
- Relational database: data in tables (relations) of rows/records/tuples and columns/fields/attributes.
Keys#
Primary key - uniquely identifies a record, cannot be blank. Composite key - two or more fields together form the key. Foreign key - a field referring to the primary key of another table (links tables). Candidate and alternate keys are the other possible unique fields.
प्राथमिक कुंजी (primary key) हर रिकॉर्ड को अद्वितीय रूप से पहचानती है और खाली नहीं हो सकती। विदेशी कुंजी (foreign key) दूसरी तालिका की प्राथमिक कुंजी से जुड़ती है और तालिकाओं में संबंध बनाती है।
LibreOffice Base#
Database file extension: .odb. Objects: tables, queries, forms, reports.
| Data type (HSQLDB) | Use |
|---|---|
| INTEGER, BIGINT | whole numbers |
| DECIMAL / NUMERIC | money, marks |
| VARCHAR | text of variable length |
| CHAR | fixed-length text |
| DATE, TIME, TIMESTAMP | dates and times |
| BOOLEAN | yes/no |
Create tables in Design View or with the wizard. Relationships (Tools → Relationships): one-to-one, one-to-many, many-to-many.
Queries and SQL#
A query retrieves data matching conditions. In Base you can use the Query Wizard, Design View or SQL View. Try SQL right here on the shop database:
DML commands: INSERT INTO table VALUES (...), UPDATE table SET col = value WHERE ..., DELETE FROM table WHERE .... DDL: CREATE TABLE, ALTER TABLE, DROP TABLE.
Forms and reports#
- Form: user-friendly screen to enter, view and edit records (Form Wizard or Design View).
- Report: formatted output of table/query data for printing (Report Wizard); can group and sort data.
फ़ॉर्म डेटा डालने और देखने के लिए सरल स्क्रीन है, जबकि रिपोर्ट तालिका या क्वेरी के डेटा को छपाई योग्य रूप में प्रस्तुत करती है। क्वेरी से शर्तों के अनुसार डेटा निकाला जाता है।
Exam tips#
- Identify primary and foreign keys in two given tables; write simple SELECT queries.