PGoCareerGoCareer prep tools
Home
LoginSign up
  • Java
  • Python
  • AI
  • React
  • Angular
  • PHP
  • Node.js
  • SQL
  • DSA
  • HTML
  • CSS
  • JS
  • Spring
  • ML
  • MongoDB

SQL · Theory

Constraints

← All stacks

Theory

31/439

Constraints

Constraints is a SQL idea you prove with lookup by roll, not with a slogan.

Constraints order — meaning → PRIMARY KEY(roll) + INDEX → one limit. Dumping ten features helps nobody.

Without Constraints, a big table gets messy and lookup by roll is hard to trust.

Constraints shows up in a big table. Name lookup by roll, not “a real-world scenario”.

Constraints trap — indexing a low-cardinality flag only. Arun loses marks for that every viva.

After Constraints, Arun should still remember indexing a low-cardinality flag only.

Close Constraints with — “If I skip it, lookup by roll goes wrong like this: indexing a low-cardinality flag only.”

Exam tip

Say Constraints in one breath, then PRIMARY KEY(roll) + INDEX, then indexing a low-cardinality flag only.

Constraints — sample query

-- Constraints
CREATE TABLE demo (
  id INTEGER PRIMARY KEY,
  label TEXT NOT NULL,
  qty INTEGER DEFAULT 0
);
INSERT INTO demo (id, label, qty) VALUES
  (1, 'alpha', 2),
  (2, 'beta', 5);
SELECT label, qty FROM demo WHERE qty >= 2 ORDER BY qty DESC;

Constraints: create two demo rows, then SELECT qty >= 2 ordered. Say which labels come back.

Short notes

  • DefConstraints — Arun uses it for lookup by roll in a big table.
  • RuleConstraints → PRIMARY KEY(roll) + INDEX.
  • RememberConstraints + InnoDB (a big table).
  • UseConstraints in a big table (lookup by roll).
  • TrapConstraints — indexing a low-cardinality flag only.
  • ExConstraints → lookup by roll.

Questions

1

Define Constraints without jargon. Then point at lookup by roll.

2

Where does Constraints show up in a big table?

3

Viva: one wrong answer people give for Constraints.

4

Show Constraints in InnoDB terms — three lines max.

Previous← QueriesNextINSERT Record →
P

GoCareerGo

Utilities · Preparation Hub · Resume · CV · Tools — one workspace.

Workspace

DashboardProfilePreparation HubResume builderCV builderCareer planning

PDF Tools

Merge PDFSplit PDFCompress PDFImage to PDFAll toolsJobs

Image & QR

Compress ImageResize ImageQR ScannerQR GeneratorBlogIT interview prep

Company

FAQFeedbackContactPrivacyTermsSitemap

© 2026 GoCareerGo. Keep moving forward.