haya.Learning made clear
Unit IV · Databases and database systems
9 min readConcept sheetOften a 5- or 10-mark answer

Database concepts and the relational model

A database is an organised collection of related data; a relational database stores it in linked tables joined by keys.

Data hierarchyBit → byte → field → record → table → database
TableRows = records; columns = fields
Primary keyUniquely identifies each record
Foreign keyLinks to another table's primary key

The data hierarchy

File-based approach vs database approach

File-based approachEach department keeps its own separate files. This causes data redundancy (the same data stored many times), inconsistency (copies disagree) and difficult sharing.
Database approachOne shared, integrated store managed by a DBMS. Less redundancy, consistent data, easy sharing, better security and backup.

A relational table: Customer

CustomerID (PK)NameCityCredit limit (Rs.)
C001Nimal PereraKandy100,000
C002Fathima RizwanColombo250,000
C003Kumar RajanJaffna75,000

A linked table: Order

OrderID (PK)DateCustomerID (FK)Amount (Rs.)
O1012026-03-02C00245,000
O1022026-03-02C00112,500
O1032026-03-05C0028,750

How the keys link the tables

CustomerID is the primary key of Customer: no two customers share it. The same field in Order is a foreign key: it points back to the customer who placed each order. So the database can tell that Fathima Rizwan (C002) placed orders O101 and O103, worth 45,000 + 8,750 = Rs. 53,750, without storing her name and city again in every order.

Key terms

TermMeaning
Relation (table)Data about one subject, in rows and columns
Record (row, tuple)All the data about one item, e.g. one customer
Field (column, attribute)One kind of data, e.g. City
Primary keyField that uniquely identifies each record
Foreign keyField in one table that matches the primary key of another
Composite keyTwo or more fields that together identify a record
Candidate keyAny field that could serve as the primary key

Advantages and disadvantages of databases

AdvantagesLess redundancy, consistent and accurate data, easy sharing, central security, backup and recovery, quick queries and reports, data independence from programs.
DisadvantagesCost of software and hardware, complexity, need for skilled staff, and a failure can affect every user at once.
In Sri Lankan business

A Sri Lankan supermarket chain or telco keeps customers, products and transactions in linked tables. One customer ID (the primary key) appears as a foreign key in every bill, so a loyalty card shows points earned in any branch.

Exam angle

Short answer: “What is a primary key?” A field (or fields) whose value uniquely identifies each record in a table, e.g. CustomerID.

Structured question: “Distinguish between the file-based approach and the database approach.” Files: separate departmental files, redundancy, inconsistency, poor sharing. Database: one integrated store under a DBMS, less redundancy, consistency, sharing and security.

Essay: “Explain the relational database concept with an example.” Explain the data hierarchy, tables, records and fields, primary and foreign keys, show two linked tables, and give advantages over files.

Remember it

Row = record, column = field, table = relation. The PK is the unique ID in its own table; the FK is the same ID borrowed by another table to link them.