Skip to content
GK24
GK NotesComputer AwarenessDatabases and DBMS

Databases and DBMS: Models, Keys, SQL and Normalisation

Notes on databases and DBMS for exams: data models, tables and keys, SQL command groups, normalisation, ACID properties and popular database software.

By · Published · 4 min read

Databases and DBMS: Models, Keys, SQL and Normalisation — GK24 title card
Databases and DBMS: Models, Keys, SQL and Normalisation — GK24 title card

A database is an organised collection of related data that a computer can store, search and update without losing its structure. A Database Management System (DBMS) is the software that sits between the user and that stored data: it creates the database, accepts queries, enforces rules and returns results. Examiners in banking, SSC and railway papers treat this chapter as pure definition work, so the marks go to students who know the vocabulary exactly.

Why a DBMS replaced file systems

Before database software, every program kept its own data file. The same address was typed into three files, one copy was corrected and the others were not, and no program could read another's file. A DBMS removes these faults. It reduces data redundancy, so a fact is stored once. It keeps data consistent, because one correction reaches every user. It shares data among many users at the same time through concurrency control. It protects data by giving each user only the rights the administrator grants. It also supports backup and recovery, so a power failure does not destroy the day's work. The cost is that a DBMS is large, needs trained staff and needs more memory than a simple file.

Data models, oldest to newest

A data model decides how records are joined to one another. The hierarchical model, used in IBM's IMS in the 1960s, is the oldest: records form a tree and each child has exactly one parent. The network model allows a child to have many parents, so it stores a graph. The relational model, proposed by Edgar Frank Codd in 1970, stores everything in simple two-dimensional tables and joins them by matching values, and it is the model behind almost every exam question. The object-oriented model stores objects with their methods and is the newest of the four.

The words for a table and its parts

Everyday wordRelational termMeaning
TableRelationThe whole two-dimensional structure
Row or recordTupleOne complete entry, such as one student
Column or fieldAttributeOne property, such as roll number
Number of columnsDegreeCounted on the attributes
Number of rowsCardinalityCounted on the tuples
Allowed valuesDomainThe set a column may draw from

Keys: the heart of the chapter

  • Super key: any set of attributes that identifies a row uniquely.
  • Candidate key: a minimal super key, with no spare attribute in it.
  • Primary key: the candidate key the designer chooses; it can never be null and never repeat.
  • Alternate key: a candidate key that was not chosen as the primary key.
  • Composite key: a primary key made of two or more columns together.
  • Foreign key: a column that holds values of another table's primary key and so links the two tables.

SQL and its four command groups

Structured Query Language is the standard language of relational databases. It was created at IBM in the 1970s as SEQUEL and is a non-procedural language: the user states what is wanted, not how to fetch it. Its commands fall into groups that papers ask by name. DDL, the Data Definition Language, changes structure: CREATE, ALTER, DROP, TRUNCATE and RENAME. DML, the Data Manipulation Language, changes or reads the rows: INSERT, UPDATE, DELETE and SELECT. DCL, the Data Control Language, handles rights with GRANT and REVOKE. TCL, the Transaction Control Language, closes or undoes a transaction with COMMIT, ROLLBACK and SAVEPOINT. Remember the trap: DELETE removes chosen rows and can be rolled back, while TRUNCATE empties the whole table as a structural command.

Normalisation and the ACID properties

Normalisation splits a large table into smaller ones so that the same fact is not repeated and an update cannot leave the database half correct. First normal form removes repeating groups and keeps every value atomic. Second normal form removes partial dependency on part of a composite key. Third normal form removes transitive dependency, where a non-key column depends on another non-key column. Boyce-Codd normal form is a stricter form of the third. A transaction, meanwhile, must satisfy four properties known by the word ACID: atomicity, so all its steps happen or none do; consistency, so the database moves from one valid state to another; isolation, so parallel transactions do not disturb each other; and durability, so a committed change survives a crash.

Software students should be able to name

Oracle, MySQL, PostgreSQL, Microsoft SQL Server, IBM Db2 and SQLite are relational systems; Microsoft Access is the desktop DBMS bundled with Office. MongoDB is a NoSQL system that stores documents instead of rows and is asked as the odd one out. The person who designs and maintains the whole system is the Database Administrator, and the diagram that shows entities, attributes and relationships before a table is built is the Entity Relationship diagram, drawn with rectangles for entities, ovals for attributes and diamonds for relationships.

Exam Point of View

Papers ask this chapter as vocabulary. Expect the oldest data model (hierarchical), the proposer of the relational model (E. F. Codd, 1970), the relational word for a row or a column, and the meaning of degree against cardinality. Key questions are certain: which key cannot be null, which key links two tables, and the difference between a candidate key and an alternate key. SQL is asked by command group, so fix CREATE and TRUNCATE as DDL, INSERT and SELECT as DML, GRANT and REVOKE as DCL, and COMMIT and ROLLBACK as TCL. The classic traps are DELETE against TRUNCATE, cardinality against degree, and picking MongoDB when the question asks for a relational system. One-mark full forms of DBMS, RDBMS, SQL, DDL, DML and ACID are almost free marks.

Important Facts

Full form of DBMSDatabase Management System
Oldest data modelHierarchical model (used in IBM IMS)
Relational model proposed byEdgar Frank Codd, in 1970
Row and column in relational termsRow is a tuple, column is an attribute
Degree and cardinalityDegree is the number of attributes, cardinality the number of tuples
Key that cannot be nullPrimary key
Key that links two tablesForeign key
DDL commandsCREATE, ALTER, DROP, TRUNCATE, RENAME
DML commandsINSERT, UPDATE, DELETE, SELECT
DCL commandsGRANT, REVOKE
TCL commandsCOMMIT, ROLLBACK, SAVEPOINT
ACIDAtomicity, Consistency, Isolation, Durability
NoSQL document databaseMongoDB
Desktop DBMS in MS OfficeMicrosoft Access

Practice MCQs on this topic

Q1.Computer AwarenessAsked in: Delhi · 7 Aug 2021, Shift 2Easy

Which of the following is the oldest database model?

  1. A.Hierarchical
  2. B.Object oriented
  3. C.Deductive
  4. D.Relational
Show answer
Correct answer: A. Hierarchical

The hierarchical model is the first data model used in commercial database software; IBM built its Information Management System on it in the 1960s for the Apollo programme.

Q2.Computer AwarenessMedium

Who proposed the relational model of databases?

  1. A.Charles Babbage
  2. B.Edgar Frank Codd
  3. C.Dennis Ritchie
  4. D.James Gosling
Show answer
Correct answer: B. Edgar Frank Codd

Codd, a British computer scientist working at IBM, set out the relational model in a paper published in 1970, proposing that all data be held in simple two-dimensional tables and joined by matching values rather than by fixed pointers.

Q5.Computer AwarenessMedium

Which SQL command removes all the rows of a table but keeps the table structure, and is classified as a DDL command?

  1. A.DELETE
  2. B.DROP
  3. C.TRUNCATE
  4. D.ERASE
Show answer
Correct answer: C. TRUNCATE

TRUNCATE empties a table in one operation, leaving the columns, data types and constraints in place so that the table can be filled again at once; because it changes the object rather than selected rows it is grouped with the Data Definition Language and it is much faster than deleting…

Q7.Computer AwarenessEasy

An attribute of one table that refers to the primary key of another table is called a:

  1. A.Candidate key
  2. B.Foreign key
  3. C.Composite key
  4. D.Secondary index
Show answer
Correct answer: B. Foreign key

A foreign key is the column that stores values belonging to the primary key of another table, so a marks table can carry the roll number of a student table and the two tables can then be joined; the database uses it to enforce referential integrity, refusing a value that…

Q10.Computer AwarenessHard

Removing partial dependency of a non-key attribute on part of a composite primary key brings a table to which normal form?

  1. A.First normal form
  2. B.Second normal form
  3. C.Third normal form
  4. D.Boyce-Codd normal form
Show answer
Correct answer: B. Second normal form

A table is in second normal form when it is already in first normal form and no non-key attribute depends on only a part of a composite primary key; such a partial dependency is removed by moving that attribute into a table of its own.

Q11.Computer AwarenessMedium

Which of the following is a NoSQL database?

  1. A.Oracle
  2. B.MySQL
  3. C.MongoDB
  4. D.Microsoft SQL Server
Show answer
Correct answer: C. MongoDB

MongoDB stores data as documents in a flexible, JSON-like form instead of as rows in tables with a fixed set of columns, and it is queried through its own interface rather than mainly through SQL, which makes it the standard example of a NoSQL database in exam papers.

Frequently Asked Questions

What is the difference between a database and a DBMS?

A database is the stored collection of related data. A DBMS is the software that creates that database and works on it, accepting queries, enforcing rules, controlling access and returning results. MySQL is a DBMS; the student records kept inside it are the database.

Which key can never be null and never repeat?

The primary key. It is the candidate key chosen to identify every row of a table, so a null value or a repeated value would make one row impossible to find. A candidate key that was not chosen becomes an alternate key.

What is the difference between DELETE and TRUNCATE?

DELETE is a DML command that removes the rows a WHERE clause selects and can be undone with ROLLBACK before a commit. TRUNCATE is a DDL command that empties the whole table at once, keeps the structure and is far faster because it does not log every row.

What is the difference between degree and cardinality?

Degree is the number of attributes, that is the number of columns in the table. Cardinality is the number of tuples, that is the number of rows. A table with five columns and two hundred rows has degree five and cardinality two hundred.

Why is normalisation done?

To remove repeated data and the update problems it causes. Splitting one wide table into related smaller tables means a fact is stored once, so an update cannot leave one copy corrected and another wrong, and space is saved. 1NF removes repeating groups, 2NF partial dependency and 3NF transitive dependency.

Is MongoDB a relational database?

No. MongoDB is a NoSQL database that stores data as documents rather than as rows in fixed tables, so it does not use SQL as its main language. Oracle, MySQL, PostgreSQL, Microsoft SQL Server and IBM Db2 are the relational systems asked in exams.

Sources

  • Computer Science, Class XII, Unit: Database Concepts and Structured Query Language — NCERT
  • Informatics Practices, Class XII, Unit: Database Query using SQL — NCERT
View all