Your country

Tools that support it use your country for local currency, number formats, units and paper size. Your choice is saved only in this browser.

Type a name or a two-letter code. Use the up and down arrow keys to move through the countries, Enter to choose one and Escape to close.

Database Management Systems (DBMS)  Module 16 – GATE and interview readiness

GATE databases: syllabus map and strategy

Every topic of the CS and DA database syllabi mapped to lessons, how MCQ, MSQ and NAT questions are marked, when a guess pays, and a revision plan.

  • Intermediate
  • 25 minutes
  • Examples run with sql.js 1.14.2
  • By MySmartCoPilot
Free: 25 minutes

What you will learn

  • Map every line of the GATE 2027 CS and DA database syllabi to lessons in this track
  • Apply the official marking scheme: MCQ, MSQ, NAT and negative marking
  • Decide when a guess has a positive expected value
  • Plan revision with spaced repetition and timed sectional practice

Before you start

What you’ll learn · Before you start

What you will learn

  • Map every line of the GATE 2027 CS and DA database syllabi to lessons in this track
  • Apply the official marking scheme: MCQ, MSQ, NAT and negative marking
  • Decide when a guess has a positive expected value
  • Plan revision with spaced repetition and timed sectional practice

Before you start

On this page

GATE examines databases in two of its papers. In the Computer Science and Information Technology paper (CS), databases is Section 9 of the syllabus: the ER model; the relational model with relational algebra, tuple calculus and SQL; integrity constraints and normal forms; file organisation and indexing, with B and B+ trees as the named example; and transactions with concurrency control. In the Data Science and Artificial Intelligence paper (DA), Section 5, “Database Management and Warehousing”, repeats most of that list, leaves out transactions and concurrency control, and adds data types, data transformation and data-warehouse modelling. This lesson maps every one of those topics to the lessons of this track, explains how the paper is marked, works out exactly when answering a question you are unsure of raises your expected score, and ends with a revision plan built on spaced reviews and timed practice sets.

GATE 2027

GATE 2027 is organised by IIT Madras as a computer-based test. It is held over three weekends in February, in a forenoon and an afternoon session, and its results are announced in March; the official dates page adds that all dates are liable to change. A candidate may take one paper or two, and CS with DA is one of the two-paper combinations in the information brochure’s tentative list. A GATE 2027 score stays valid for three years from the results. Qualifying is not the same as a seat or a job: the brochure says that admission and recruitment depend on the criteria of each institute and each employer.

Every syllabus topic and where it is taught

The CS syllabus names eleven topics in five short sentences. The DA syllabus names twelve, in one long sentence of its Section 5:

ER-model, relational model: relational algebra, tuple calculus, SQL, integrity constraints, normal form, file organization, indexing, data types, data transformation such as normalization, discretization, sampling, compression; data warehouse modelling: schema for multidimensional data models, concept hierarchies, measures: categorization and computations.

The list gives the fourteen topics in the order of the CS list, with the three that only DA names at the end: the papers that name each topic, where this track teaches it, and what you should be able to do. Where a topic’s lessons are still to come, the link goes to its module on the track page, which lists them.

Two words in the DA list need care. “Normal form” is schema design, the same topic as the CS paper’s normal forms, while “normalization” sits among data-preparation steps and means rescaling values; the warm-up questions at the end of this lesson come back to it. “Data types” is not defined by the syllabus, so learn both readings: the column types a schema declares, and the kinds of attribute that data analysis distinguishes. The three classes of measure in the last row come from the paper that introduced the data cube operator.

The map as data, checked by a query

A table of links goes stale quietly, when lessons are added or move. So the same map is also kept as data. The program below stores the topics of both syllabi in one table and the lessons that teach them in another, then asks four questions of them. Run it, or change a row and run it again.

The syllabus map as two tables, checked by queries SQL · syllabus_map.sql
-- The databases sections of the CS and DA syllabi, one row per topic, and the lessons of this track that teach
-- each topic. n is the topic's place in the CS list; the three topics only DA names come after it.
CREATE TABLE syllabus (
  paper TEXT NOT NULL CHECK (paper IN ('CS', 'DA')),
  n INTEGER NOT NULL,
  topic TEXT NOT NULL,
  PRIMARY KEY (paper, topic)
);
INSERT INTO syllabus VALUES
  ('CS', 1, 'ER model'), ('CS', 2, 'relational model'), ('CS', 3, 'relational algebra'),
  ('CS', 4, 'tuple calculus'), ('CS', 5, 'SQL'), ('CS', 6, 'integrity constraints'),
  ('CS', 7, 'normal forms'), ('CS', 8, 'file organisation'), ('CS', 9, 'indexing'),
  ('CS', 10, 'transactions'), ('CS', 11, 'concurrency control'),
  ('DA', 1, 'ER model'), ('DA', 2, 'relational model'), ('DA', 3, 'relational algebra'),
  ('DA', 4, 'tuple calculus'), ('DA', 5, 'SQL'), ('DA', 6, 'integrity constraints'),
  ('DA', 7, 'normal forms'), ('DA', 8, 'file organisation'), ('DA', 9, 'indexing'),
  ('DA', 12, 'data types'), ('DA', 13, 'data transformation'), ('DA', 14, 'warehouse modelling');

-- Which lesson teaches which topic. A lesson may teach more than one topic.
CREATE TABLE teaches (topic TEXT NOT NULL, lesson TEXT NOT NULL, PRIMARY KEY (topic, lesson));
INSERT INTO teaches VALUES
  ('ER model', 'er-entities-and-attributes'), ('ER model', 'er-relationships-and-constraints'),
  ('ER model', 'weak-entities-and-eer'), ('ER model', 'er-to-relational-mapping'),
  ('ER model', 'er-design-case-study'),
  ('relational model', 'relations-tuples-and-domains'), ('relational model', 'keys-and-superkeys'),
  ('relational algebra', 'relational-algebra-basics'), ('relational algebra', 'relational-algebra-joins'),
  ('relational algebra', 'division-and-extended-algebra'),
  ('tuple calculus', 'tuple-relational-calculus'),
  ('SQL', 'sql-logical-evaluation-order'), ('SQL', 'null-and-three-valued-logic'),
  ('SQL', 'grouping-and-aggregation-semantics'), ('SQL', 'subqueries-exists-any-all'),
  ('SQL', 'views-and-materialized-views'), ('SQL', 'recursive-queries-and-datalog'),
  ('SQL', 'triggers-procedures-and-functions'), ('SQL', 'access-control-and-sql-injection'),
  ('integrity constraints', 'keys-and-superkeys'), ('integrity constraints', 'integrity-constraints'),
  ('normal forms', 'redundancy-and-anomalies'), ('normal forms', 'functional-dependencies-and-armstrong-axioms'),
  ('normal forms', 'attribute-closure-and-candidate-keys'), ('normal forms', 'canonical-cover-and-fd-equivalence'),
  ('normal forms', 'normal-forms-1nf-2nf-3nf'), ('normal forms', 'bcnf-and-3nf-tradeoff'),
  ('normal forms', 'lossless-join-and-dependency-preservation'),
  ('normal forms', '3nf-synthesis-and-bcnf-decomposition'), ('normal forms', 'multivalued-dependencies-4nf-5nf'),
  ('file organisation', 'storage-media-and-io-costs'), ('file organisation', 'pages-records-and-slotted-pages'),
  ('file organisation', 'file-organisations'),
  ('indexing', 'index-basics'), ('indexing', 'b-trees-and-b-plus-trees'),
  ('indexing', 'b-plus-tree-insertion-and-deletion'), ('indexing', 'b-tree-indexes-in-practice'),
  ('indexing', 'hashing-extendible-and-linear'),
  ('transactions', 'transactions-and-acid'), ('transactions', 'conflict-serializability'),
  ('transactions', 'view-serializability'), ('transactions', 'recoverable-and-cascadeless-schedules'),
  ('transactions', 'isolation-levels-and-anomalies'),
  ('concurrency control', 'two-phase-locking'), ('concurrency control', 'deadlock-handling'),
  ('concurrency control', 'multiple-granularity-and-phantoms'), ('concurrency control', 'timestamp-ordering-and-occ'),
  ('concurrency control', 'mvcc-and-snapshot-isolation'), ('concurrency control', 'ssi-and-concurrency-patterns'),
  ('data types', 'relations-tuples-and-domains'), ('data types', 'data-preprocessing-for-analytics'),
  ('data transformation', 'data-preprocessing-for-analytics'),
  ('warehouse modelling', 'data-warehousing-and-olap');

-- 1. Every topic, the papers that name it, and how many lessons teach it.
SELECT topic,
       CASE WHEN max(paper = 'CS') THEN 'yes' ELSE 'no' END AS in_cs,
       CASE WHEN max(paper = 'DA') THEN 'yes' ELSE 'no' END AS in_da,
       (SELECT count(*) FROM teaches t WHERE t.topic = s.topic) AS lessons
FROM syllabus AS s
GROUP BY topic
ORDER BY min(n);

-- 2. The check: syllabus rows that no lesson teaches (an anti-join). It must be 0.
SELECT count(*) AS topics_without_a_lesson
FROM syllabus AS s
WHERE NOT EXISTS (SELECT 1 FROM teaches AS t WHERE t.topic = s.topic);

-- 3. What one paper names and the other does not.
SELECT topic AS only_in_da FROM syllabus WHERE paper = 'DA'
EXCEPT
SELECT topic FROM syllabus WHERE paper = 'CS'
ORDER BY 1;

SELECT topic AS only_in_cs FROM syllabus WHERE paper = 'CS'
EXCEPT
SELECT topic FROM syllabus WHERE paper = 'DA'
ORDER BY 1;

Output

┌───────────────────────┬───────┬───────┬─────────┐
│         topic         │ in_cs │ in_da │ lessons │
├───────────────────────┼───────┼───────┼─────────┤
│ ER model              │ yes   │ yes   │ 5       │
│ relational model      │ yes   │ yes   │ 2       │
│ relational algebra    │ yes   │ yes   │ 3       │
│ tuple calculus        │ yes   │ yes   │ 1       │
│ SQL                   │ yes   │ yes   │ 8       │
│ integrity constraints │ yes   │ yes   │ 2       │
│ normal forms          │ yes   │ yes   │ 9       │
│ file organisation     │ yes   │ yes   │ 3       │
│ indexing              │ yes   │ yes   │ 5       │
│ transactions          │ yes   │ no    │ 5       │
│ concurrency control   │ yes   │ no    │ 6       │
│ data types            │ no    │ yes   │ 2       │
│ data transformation   │ no    │ yes   │ 1       │
│ warehouse modelling   │ no    │ yes   │ 1       │
└───────────────────────┴───────┴───────┴─────────┘
┌─────────────────────────┐
│ topics_without_a_lesson │
├─────────────────────────┤
│ 0                       │
└─────────────────────────┘
┌─────────────────────┐
│     only_in_da      │
├─────────────────────┤
│ data transformation │
│ data types          │
│ warehouse modelling │
└─────────────────────┘
┌─────────────────────┐
│     only_in_cs      │
├─────────────────────┤
│ concurrency control │
│ transactions        │
└─────────────────────┘

Recorded with sql.js 1.14.2 (SQLite 3.49.1) on macOS 26 arm64. To run it yourself: sqlite3 -box :memory: < syllabus_map.sql

The first result is the map at a glance: fourteen topics, the papers that name each one, and how many lessons teach it, from 1 for tuple calculus to 9 for normal forms. Normal forms has the most because the track builds up functional dependencies, closures and covers step by step before it reaches the normal forms themselves.

The second result is the check. It is an anti-join: NOT EXISTS keeps the syllabus rows that no lesson row matches, and their count must be 0. If a topic ever lost its last lesson, the count would rise above 0 on the next run. The subqueries lesson explains why NOT EXISTS is the safe way to write such a check when columns can be NULL.

The last two results use EXCEPT, the set difference of SQL, to list what one paper names and the other does not. DA alone names data types, data transformation and warehouse modelling; CS alone names transactions and concurrency control. A candidate who takes both papers studies the union of the two lists.

How the paper is marked

Every GATE paper has 65 questions worth 100 marks and lasts three hours. Ten of the questions, worth 15 marks, are General Aptitude: five of 1 mark and five of 2 marks. In the CS paper the other 85 marks are the subject, and 13 of them are engineering mathematics; in the DA paper all 85 belong to its subject sections. Each question is worth 1 or 2 marks and has one of three types:

  • MCQ, multiple choice: choose the one correct option of four. A wrong answer costs 1/3 of a mark on a 1-mark question and 2/3 of a mark on a 2-mark question.
  • MSQ, multiple select: choose every correct option, since one or more of the four are correct. A wrong answer costs nothing, but there are no partial marks: only the exact set of correct options earns the marks.
  • NAT, numerical answer: type a signed number with the on-screen keypad; there are no options. A wrong answer costs nothing, and there are no partial marks either.

An unanswered question scores 0, whatever its type. Calculations are done on the on-screen virtual calculator, and the brochure advises rounding a NAT answer only at the end, to the number of decimal places the question asks for.

How many of the subject marks are about databases is not published: the paper pattern gives totals for General Aptitude, engineering mathematics and the subject, and nothing per syllabus section, so this lesson estimates no weights either. One figure is worth keeping instead, because it sets the pace of every practice set: 180 minutes for 100 marks is 1.8 minutes per mark.

When a guess raises your score

Negative marking turns “should I answer this?” into arithmetic. Take an MCQ worth m marks that you would get right with probability p. Answering earns m marks with probability p and loses m/3 with probability 1 − p, so on average it is worth pm − (1 − p)m/3, which simplifies to m(4p − 1)/3. That is zero when p is exactly 1/4 and positive whenever p is larger, whatever the question’s marks. A blind guess among four options has p = 1/4, so it is worth nothing on average; every option you rule out with real knowledge raises p, and with it the value of answering.

Expected marks from answering, by options left and by accuracy SQL · guessing.sql
-- Expected marks from answering under the paper's marking: a right answer earns the question's marks (m), a wrong
-- MCQ answer costs a third of them, a wrong MSQ or NAT answer costs nothing, and a blank scores 0.
-- If you are right with probability p, an MCQ is worth p*m - (1 - p)*m/3 = m*(4p - 1)/3 on average.

-- 1. A random pick among the k options you have not ruled out: p = 1/k, so the value is m*(4 - k)/(3k).
WITH RECURSIVE options_left(k) AS (SELECT 4 UNION ALL SELECT k - 1 FROM options_left WHERE k > 1)
SELECT m.marks, k AS options_left, '1/' || k AS chance_right,
       round(m.marks * (4 - k) / (3.0 * k), 3) AS expected_marks
FROM (SELECT 1 AS marks UNION ALL SELECT 2) AS m, options_left
ORDER BY m.marks, k DESC;

-- 2. Net marks per MCQ attempted, by accuracy (the share of your attempts that are right).
WITH accuracy(a) AS (VALUES (0.25), (0.4), (0.5), (0.7), (0.9))
SELECT a AS accuracy,
       round((4 * a - 1) / 3, 3) AS per_1_mark_mcq,
       round(2 * (4 * a - 1) / 3, 3) AS per_2_mark_mcq
FROM accuracy;

-- 3. An MSQ with four options has 2^4 - 1 = 15 possible non-empty answers, and a wrong one costs nothing.
SELECT (1 << 4) - 1 AS possible_msq_answers,
       round(1.0 / 15, 3) AS blind_guess_right,
       round(2.0 / 15, 3) AS expected_marks_2_mark_msq;

Output

┌───────┬──────────────┬──────────────┬────────────────┐
│ marks │ options_left │ chance_right │ expected_marks │
├───────┼──────────────┼──────────────┼────────────────┤
│ 1     │ 4            │ 1/4          │ 0.0            │
│ 1     │ 3            │ 1/3          │ 0.111          │
│ 1     │ 2            │ 1/2          │ 0.333          │
│ 1     │ 1            │ 1/1          │ 1.0            │
│ 2     │ 4            │ 1/4          │ 0.0            │
│ 2     │ 3            │ 1/3          │ 0.222          │
│ 2     │ 2            │ 1/2          │ 0.667          │
│ 2     │ 1            │ 1/1          │ 2.0            │
└───────┴──────────────┴──────────────┴────────────────┘
┌──────────┬────────────────┬────────────────┐
│ accuracy │ per_1_mark_mcq │ per_2_mark_mcq │
├──────────┼────────────────┼────────────────┤
│ 0.25     │ 0.0            │ 0.0            │
│ 0.4      │ 0.2            │ 0.4            │
│ 0.5      │ 0.333          │ 0.667          │
│ 0.7      │ 0.6            │ 1.2            │
│ 0.9      │ 0.867          │ 1.733          │
└──────────┴────────────────┴────────────────┘
┌──────────────────────┬───────────────────┬───────────────────────────┐
│ possible_msq_answers │ blind_guess_right │ expected_marks_2_mark_msq │
├──────────────────────┼───────────────────┼───────────────────────────┤
│ 15                   │ 0.067             │ 0.133                     │
└──────────────────────┴───────────────────┴───────────────────────────┘

Recorded with sql.js 1.14.2 (SQLite 3.49.1) on macOS 26 arm64. To run it yourself: sqlite3 -box :memory: < guessing.sql

Read the three results in turn:

  1. Ruling options out. Rule out one option and a random pick among the other three is worth +0.111 of a mark on a 1-mark question and +0.222 on a 2-mark question. Rule out two and it is worth a third of the question: +0.333 and +0.667.
  2. Accuracy. The second table applies the same formula to your accuracy, the share of your answers that are right. At 70 % accuracy each 1-mark MCQ you attempt is worth 0.6 marks after penalties, and at 50 % it is worth a third of a mark. Attempting stops paying only at 25 %.
  3. MSQ and NAT. An MSQ with four options has 15 possible non-empty answers, so even a blind guess is right one time in 15, and a wrong one costs nothing; a wrong NAT answer costs nothing either. Your best attempt at an MSQ or a NAT question can only add marks, so never leave one blank.

Expected value is an average over many questions, not a promise for one, but the rule it gives settles most cases in the exam hall: answer an MCQ when you can honestly rule out at least one option, leave it when you cannot, and answer every MSQ and NAT question.

Here is the arithmetic on one mock. You attempted 14 MCQs, 6 of 1 mark and 8 of 2 marks, and got 4 and 5 of them right. The right answers earn 4 + 10 = 14 marks. The 2 wrong 1-mark answers cost 2/3 of a mark and the 3 wrong 2-mark answers cost 2 marks, so the MCQs scored 14 − 0.67 − 2 = 11.33. Your accuracy was 9 out of 14, about 64 %, far above the 25 % break-even, so attempting all 14 was the right call even though 5 of them were wrong.

Exam Score Calculator with Negative Marking (India) Score a whole mock from your right and wrong answers of each type under GATE marking, with your accuracy and whether guessing paid.

A revision plan built on spacing and timed sets

The syllabus falls into four strands, plus the three topics that only DA adds. Inside each strand the topics build on each other, so learn them in the order shown. Across strands the order matters less, apart from keys, which the design strand needs first.

The databases syllabus as four strands, each learnt in order, and the three topics only the DA paper names.1. Model and query2. Design3. Storage4. TransactionsDA paper onlyER modelRelational model,keys, integrityconstraintsRelational algebra,tuple calculusSQLFunctionaldependenciesNormal formsFile organisationIndexing:B and B+ treesTransactionsand schedulesConcurrencycontrolData typesData transformationWarehouse modelling

Four strands to learn in order, plus the topics only the DA paper adds

Text description of the diagram

The diagram shows five boxes. Four of them are strands of the syllabus, numbered in the order this lesson suggests learning them; inside each strand, arrows give the order of its topics.

  1. Model and query: ER model, then the relational model with keys and integrity constraints, then relational algebra and tuple calculus, then SQL.
  2. Design: functional dependencies, then normal forms.
  3. Storage: file organisation, then indexing with B and B+ trees.
  4. Transactions: transactions and schedules, then concurrency control.

The fifth box, "DA paper only", holds data types, then data transformation, then warehouse modelling. The CS paper does not name these three topics, and the DA paper does not name the two topics of the transactions strand.

How you revise matters as much as what you revise. A large review of ten common study techniques rated two of them as the most useful: practice testing, which means answering questions rather than reading answers, and distributed practice, which means spreading study over separate sessions. It rated rereading and highlighting low, although most students report relying on them. A meta-analysis of 839 assessments of spacing in 317 experiments found that the gap between sessions that gives the best retention grows as the time you need to remember grows. For an exam some months away, that means short, repeated self-tests at widening gaps, not one long reread at the end.

A plan that follows both findings:

  1. Learn a topic, then write questions, not notes. After each lesson, write three to five questions whose answers you have to produce: a closure to compute, a schedule to test, the output of a query to predict.
  2. Review on a widening schedule. Answer each question again about one day, three days and a week after you first study the topic, then every two or three weeks until the exam. A question you get wrong starts the schedule again.
  3. Add one timed set a week once a strand is learnt. Mix MCQ, MSQ and NAT questions and keep to the paper’s pace of 1.8 minutes a mark: 27 minutes for a 15-mark set.
  4. Sort every lost mark by its cause. You did not know it, misread the question, slipped in a calculation, or ran out of time. Each cause has its own fix: a new question, slower reading of the stem, a checking step, or moving on sooner.
  5. Score every set with the real marking, so the habit of answering only when your chance beats one in four is practised before the exam rather than discovered in it.

Six weeks of that plan, for a candidate who already knows some SQL, could look like this:

Week Learn, in strand order Timed set at 1.8 minutes a mark
1 ER model, relational model, keys, integrity constraints None yet: daily reviews only
2 Relational algebra, tuple calculus, SQL 10 marks on weeks 1 and 2, in 18 minutes
3 Functional dependencies and normal forms 15 marks on weeks 1 to 3, in 27 minutes
4 File organisation and indexing 15 marks, mixed topics, in 27 minutes
5 Transactions and concurrency control (for DA: data types, data transformation and warehouse modelling) 15 marks, mixed topics, in 27 minutes
6 The causes that cost you the most marks in your log Two 15-mark sets, 27 minutes each

Reviews run every day alongside: 15 to 20 minutes of answering your own questions. With more time, give each strand longer and keep the weekly set; with less, shorten the strands but never drop the reviews.

Flashcard Maker Keep the questions you write as cards: spaced repetition decides when each one comes back, and a card you miss returns sooner.

Exercises

The exercise asks for the marking rule in SQL: one query that turns a table of your answers into a score.

Exercise · Easy · SQL

Score a mock paper with negative marking

The table responses holds one row for each question of a mock paper you took, with four columns:

  • q: the question number;
  • type: 'MCQ', 'MSQ' or 'NAT';
  • marks: 1 or 2;
  • result: 'right', 'wrong', or NULL for a question you left unanswered.

Write one query that returns one row with two columns:

  • attempted: how many questions you answered;
  • score: your marks under the paper's marking, rounded to two decimal places with round(…, 2).

A right answer earns the question's marks. A wrong MCQ answer costs a third of the question's marks, and a wrong MSQ or NAT answer costs nothing. An unanswered question scores 0, so a paper with no answers scores 0, not NULL. The sample tests run your query on three small papers and compare the row it returns with the expected one.

Starter code · score_mock.sql

-- One row: how many questions you answered, and your marks under the paper's marking.
SELECT count(*) AS attempted,
       sum(CASE WHEN result = 'right' THEN marks ELSE -marks / 3 END) AS score
FROM responses;
The sample tests · tests.yaml
# Sample tests: each one builds a small mock paper, runs your query on it and compares the row it returns.
tests:
  - name: scores a ten-question mock with right, wrong and unanswered questions of every type
    setup: |
      CREATE TABLE responses (q INTEGER PRIMARY KEY, type TEXT NOT NULL, marks INTEGER NOT NULL, result TEXT);
      INSERT INTO responses VALUES
        (1, 'MCQ', 1, 'right'),
        (2, 'MCQ', 1, 'wrong'),
        (3, 'MCQ', 2, 'right'),
        (4, 'MCQ', 2, 'wrong'),
        (5, 'MSQ', 1, 'right'),
        (6, 'MSQ', 2, 'wrong'),
        (7, 'MCQ', 1, 'wrong'),
        (8, 'NAT', 2, 'right'),
        (9, 'MCQ', 1, NULL),
        (10, 'NAT', 2, NULL);
    expected:
      columns: [attempted, score]
      rows:
        - [8, 4.67]
  - name: gives an unanswered paper a score of 0, not NULL
    setup: |
      CREATE TABLE responses (q INTEGER PRIMARY KEY, type TEXT NOT NULL, marks INTEGER NOT NULL, result TEXT);
      INSERT INTO responses VALUES
        (1, 'MCQ', 2, NULL),
        (2, 'MSQ', 1, NULL),
        (3, 'NAT', 2, NULL);
    expected:
      columns: [attempted, score]
      rows:
        - [0, 0]
  - name: charges a third of the marks for wrong MCQs only, never for wrong MSQ or NAT answers
    setup: |
      CREATE TABLE responses (q INTEGER PRIMARY KEY, type TEXT NOT NULL, marks INTEGER NOT NULL, result TEXT);
      INSERT INTO responses VALUES
        (1, 'MCQ', 1, 'wrong'),
        (2, 'MCQ', 2, 'wrong'),
        (3, 'MSQ', 2, 'wrong'),
        (4, 'NAT', 1, 'wrong');
    expected:
      columns: [attempted, score]
      rows:
        - [4, -1]
A hint

An unanswered question has a NULL result: count(result) skips NULLs, while count(*) counts every row. And in SQLite, -1 / 3 divides two integers and gives 0, so write the penalty as marks / 3.0.

The sample tests run on this device, in your browser (sql.js): nothing is sent to mysmartcopilot.com. The first run downloads SQLite (about 0.7 MB), which is kept for the next runs. A check in your browser is feedback for you, not proof that the code is right for every input.

The quiz is a ten-question mixed sample in the style of the paper: five NAT, three MCQ and two MSQ questions worth 14 marks in all, each labelled with its type and marks. Give it about 25 minutes, the paper’s pace for 14 marks, then score it with the marking above: by hand, with your query from the exercise, or with the calculator.

Check yourself

10 questions about this lesson. Every answer and why it is right is on the page, behind “Show the answer”. Your score stays in this browser.

  1. Question 1 of 10 (NAT, 1 mark) An ER diagram has two strong entity sets, Student and Course, joined by a many-to-many relationship set Enrols that has the attribute grade. What is the smallest number of relational tables that represents it without repeating any student's or course's attributes?

    Type a number.

    Show the answer to question 1

    Answer: 3 tables

    Each strong entity set becomes a table, and a many-to-many relationship needs a table of its own, Enrols(student, course, grade), whose key combines the keys of the two entities. Folding Enrols into Student or Course would repeat that table's attributes once per enrolment.

  2. Question 2 of 10 (NAT, 1 mark) R(A, B) has 6 tuples and S(B, C) has 4 tuples. What is the largest number of tuples the natural join of R and S can have?

    Type a number.

    Show the answer to question 2

    Answer: 24 tuples

    The natural join pairs tuples that agree on B. If every tuple of both relations has the same B value, every one of the 6 tuples of R matches every one of the 4 tuples of S, so the join has 6 × 4 = 24 tuples, as many as the Cartesian product.

  3. Question 3 of 10 (MSQ, 2 marks) A table t has one column x holding the three values 1, NULL and 3. Which of these queries return 2?

    Choose every answer that is right.

    Show the answer to question 3

    Answer:

    • SELECT count(*) FROM t WHERE x IS NOT NULL;
    • SELECT count(x) FROM t;

    count(x) skips NULLs, so it counts 1 and 3. count(*) counts rows, all three of them. With WHERE x IS NOT NULL two rows remain. In x <> 1, the comparison NULL <> 1 is unknown rather than true, so only the row with 3 passes and the count is 1. Under MSQ marking, only the exact set of the first and third options earns the marks.

  4. Question 4 of 10 (MCQ, 1 mark) R(A, B, C, D) has the functional dependencies A → B, B → C and C → D. Which of these is a candidate key of R?

    Choose one answer.

    Show the answer to question 4

    Answer: A

    The closure of A is ABCD (A gives B, B gives C, C gives D), so A is a superkey, and it is minimal because it is a single attribute. AB is a superkey but not minimal. B's closure is BCD and D's is D, so neither determines A.

  5. Question 5 of 10 (MCQ, 2 marks) R(A, B, C) has the functional dependencies AB → C and C → B. What is the highest normal form that R satisfies?

    Choose one answer.

    Show the answer to question 5

    Answer: 3NF but not BCNF

    The candidate keys are AB and AC (the closure of AC is ACB), so all three attributes are prime. C → B breaks BCNF because C is not a superkey, but it is allowed in 3NF because B is a prime attribute.

  6. Question 6 of 10 (NAT, 1 mark) A file holds 30,000 records of 100 bytes each, stored unspanned (no record crosses a block boundary) in blocks of 4,096 bytes. How many blocks does the file occupy?

    Type a number.

    Show the answer to question 6

    Answer: 750 blocks

    A block holds floor(4,096 / 100) = 40 whole records, and the remaining 96 bytes are left unused because records are unspanned. The file needs ceil(30,000 / 40) = 750 blocks.

  7. Question 7 of 10 (NAT, 2 marks) An internal node of a B+ tree fills one block of 4,096 bytes. A search key takes 12 bytes and a child pointer 8 bytes, and a node with p child pointers holds p − 1 keys. What is the largest possible p?

    Type a number.

    Show the answer to question 7

    Answer: 205 pointers

    The node needs 8p + 12(p − 1) ≤ 4,096 bytes, so 20p ≤ 4,108 and p ≤ 205.4. The largest whole number is 205, which uses 4,088 of the 4,096 bytes.

  8. Question 8 of 10 (MCQ, 2 marks) The schedule S is r1(X), r2(X), w1(X), w2(X), where r and w are reads and writes by transactions 1 and 2. Which statement about S is true?

    Choose one answer.

    Show the answer to question 8

    Answer: S is not conflict serializable

    r1(X) before w2(X) needs transaction 1 before 2, and r2(X) before w1(X) needs 2 before 1. The precedence graph has an edge each way, a cycle, so no serial order is conflict-equivalent to S. Both reads saw the old X, and the second write overwrites the first: a lost update.

  9. Question 9 of 10 (MSQ, 1 mark) Which of these statements about basic two-phase locking (2PL), without the strict variant, are true?

    Choose every answer that is right.

    Show the answer to question 9

    Answer:

    • Transactions can deadlock under it
    • Every schedule it allows is conflict serializable

    2PL guarantees conflict serializability: the order in which transactions reach their lock point is an equivalent serial order. It does not prevent deadlocks, since two transactions can each wait for a lock the other holds. Basic 2PL may release locks before commit, so another transaction can read an uncommitted value and have to roll back with it; strict 2PL, which holds exclusive locks until commit, prevents that. Taking a lock after releasing one is exactly what 2PL forbids.

  10. Question 10 of 10 (NAT, 1 mark) In a 2-mark MCQ you rule out two of the four options and pick one of the other two at random. A wrong answer costs 2/3 of a mark. What is the expected score of answering, rounded to two decimal places?

    Type a number.

    Show the answer to question 10

    Answer: 0.67 marks (anything from 0.665 to 0.675 counts)

    You are right with probability 1/2 and earn 2 marks, or wrong with probability 1/2 and lose 2/3: 1/2 × 2 − 1/2 × 2/3 = 1 − 1/3 = 2/3, about 0.67 marks. Leaving it blank scores 0, so answering is worth a third of the question.

Interview questions

Fresher · Under negative marking of one third, when does answering an MCQ you are unsure of raise your expected score?

When your chance of being right is greater than one in four. A question worth m marks earns m with probability p and costs m/3 with probability 1 − p, so its expected value is m(4p − 1)/3: zero at p = 1/4 and positive above it, whatever m is. A blind guess among four options sits exactly at 1/4, so it is worth nothing on average. Ruling out one option makes a guess worth 1/9 of a mark on a 1-mark question, and ruling out two makes it worth a third of the question. MSQ and NAT questions carry no negative marking, so answering them never lowers the expected score: never leave one blank.

Fresher · In the DA databases syllabus, does “normalization” mean normal forms?

No. The DA list uses the idea twice, in two senses. “Normal form”, among the relational topics, is schema normalisation: 1NF to BCNF, built on functional dependencies, the same topic as normal forms in the CS syllabus. “Normalization” in “data transformation such as normalization, discretization, sampling, compression” sits with data-preparation steps, so it means rescaling values, for example min-max scaling to the range 0 to 1, or z-scores that subtract the mean and divide by the standard deviation. When a term has two meanings, its neighbours in the list tell you which one is meant.

Key takeaways

  • The CS paper’s databases section names eleven topics. The DA paper shares nine of them, leaves out transactions and concurrency control, and adds data types, data transformation and warehouse modelling.
  • Every topic maps to lessons of this track, and the map is checked by a query: an anti-join with NOT EXISTS that must count 0.
  • A paper is 65 questions, 100 marks and three hours: 1.8 minutes per mark. A wrong MCQ costs a third of its marks, a wrong MSQ or NAT answer costs nothing, and no question gives partial marks.
  • An MCQ answer is worth m(4p − 1)/3 on average: answer when your chance of being right beats one in four, and never leave an MSQ or NAT question blank.
  • Revise by answering questions at widening gaps and by timed mixed sets scored with the real marking, not by rereading.

References

Related tools

Report a problem with this lesson

Quick answers and tool search

Type to search tools or to get a quick answer, for example 18% of 2500. Use the up and down arrow keys to move through the results, Enter to choose, and Escape to close.