⚡0 XP🔥0

Unit 3 · Database Management System | डेटाबेस प्रबंधन प्रणाली

Lesson 8 of 9 ⏱ 3 min read ✎ 1 exercises ❓ 5-question quiz ▶ Runs SQL

Database concepts, DBMS, keys, LibreOffice Base - tables, data types, relationships, queries (with SQL), forms and reports - with runnable SQL.

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:

▶ Try it Yourselfdatabase: shopSQL
Ctrl + Enter to run
▶ Try it Yourselfdatabase: shopSQL
Ctrl + Enter to run

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.

Practice Exercises

Write your code, then press Check. Your program is tested automatically.

1

Expensive products

Show name and price of all products with a price between 500 and 2000 (inclusive), cheapest first.

Database: shop (see the tables in this lesson)

Quick Quiz

Q1.

Extension of a LibreOffice Base file is

Q2.

A field that uniquely identifies each record is the

Q3.

A column in a table is also called a

Q4.

Object used to print formatted data is a

Q5.

SQL command to retrieve data is