🗂️ Databases

Database Concepts

डेटाबेस अवधारणाएँ

⏱ 2 hr3 topicsInteractive
🎯 By the end: You can explain why databases are used, define the relational-model terms, and identify candidate, primary, alternate and foreign keys.

Storing data in plain files works until the data grows — then you hit duplication, errors and chaos. A database organises data so it can be stored, searched and updated reliably. The model used almost everywhere is the relational model: data in neat tables. This chapter gives you the vocabulary the rest of the unit depends on.

1Why a database, not just files?

Imagine a school keeping student records in separate files for each teacher. Problems pile up:

  • Data redundancy — the same data (a student's address) stored in many places.
  • Data inconsistency — those copies disagree when one is updated and others aren't.
  • Difficult access & sharing — hard to search across files or let many users work safely at once.
  • Poor security & integrity — no central control over who sees or changes what.

A Database Management System (DBMS) solves these by storing data centrally with controlled access, reducing redundancy, enforcing consistency, and supporting backup and security.

Key points
  • Flat files cause redundancy (duplicated data), inconsistency (copies disagree), and poor sharing/security.
  • A DBMS stores data centrally with controlled access.
  • Benefits: less redundancy, enforced consistency, easier sharing, better security and backup.

2The relational model

In the relational model, data lives in tables. Each term has a precise name you must know:

TermMeans
RelationA table
TupleA row (one record)
AttributeA column (a field)
DomainThe set of allowed values for an attribute (e.g. marks 0–100)
DegreeThe number of attributes (columns)
CardinalityThe number of tuples (rows)
Remember the easy-to-confuse pair: Degree = columns (attributes), Cardinality = rows (tuples). A table with 5 columns and 30 rows has degree 5 and cardinality 30.
Key points
  • Relation = table, Tuple = row (record), Attribute = column (field).
  • Domain = the allowed set of values for an attribute.
  • Degree = number of columns (attributes); Cardinality = number of rows (tuples).

3Keys

A key uniquely identifies rows or links tables. The four to know:

  • Candidate Key — any attribute (or set) that can uniquely identify each row. A table may have several candidates (e.g. roll number, admission number).
  • Primary Key — the one candidate key chosen to be the main unique identifier. It cannot be NULL or duplicated.
  • Alternate Key — the candidate keys not chosen as the primary key.
  • Foreign Key — an attribute in one table that refers to the primary key of another table, linking them together.
Foreign keys create relationships. If a MARKS table has a roll column that points to the roll primary key in the STUDENT table, that roll in MARKS is a foreign key — it ties each marks record to a real student.
Key points
  • Candidate key = any attribute(s) that can uniquely identify a row; a table can have several.
  • Primary key = the chosen candidate key (unique, not NULL); alternate keys = the other candidates.
  • Foreign key = an attribute referring to another table's primary key — it links the two tables.

★ Practical: model a table

For a STUDENT table with columns roll, name, class, marks and 30 students:

  1. State its degree and its cardinality.
  2. Which attribute is the best primary key, and why?
  3. Name the relational term for a single student's record.
  4. If a separate MARKS table refers to roll, what kind of key is roll in MARKS?

Ready for the chapter test?

Answer 5 questions. Score 60% or more to mark this chapter complete.

Start the test →

💡 Log in to save your progress and earn the certificate.