Skip to content
Exercises · Q10
Q.

School uniform is available at M/s Sheetal Private Limited. They have maintained SCHOOL_UNIFORM Database with two relations viz. UNIFORM and COST. The following figure shows database schema and its state.

Attributes and Constraints

Table: UNIFORM

AttributeUCodeUNameUColor
ConstraintsPrimary KeyNot Null-

Table: COST

AttributeUCodeSizePrice
ConstraintsComposite Primary Key>0

Table: UNIFORM

UCodeUNameUColor
1ShirtWhite
2PantGrey
3SkirtGrey
4TieBlue
5SocksBlue
6BeltBlue

Table: COST

UCodeSizePrice
1M500
1L580
1XL620
2M810
2L890
2XL940
3M770
3L830
3XL910
4S150
4L170
5S180
5L210
6M110
6L140
6XL160
  1. Can they insert the following tuples to the UNIFORM Relation? Give reasons in support of your answer. i) 7, Handkerchief, NULL ii) 4, Ribbon, Red iii) 8, NULL, White
  2. Can they insert the following tuples to the COST Relation? Give reasons in support of your answer. i) 7, S, 0 ii) 9, XL, 100
Sikkim CbseNCERTSubjective· 4mImportance★★★★★
38% · 11/29 Questions
🔒 Locked · start free trial →

You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.

Start your 14-day free trial to unlock the full solution →

This question tests understanding of primary key, NOT NULL, and CHECK constraints by asking whether specific tuples violate the schema rules defined for the UNIFORM and COST relations.

Understanding Database Constraints

Before we can decide whether a tuple can be inserted, we need to understand what each constraint means and how it restricts the data.

Primary Key ensures that each value (or combination of values, in the case of a composite key) uniquely identifies a row and cannot be NULL. No two rows can have the same primary key value.

NOT NULL means the attribute must have a value in every row; it cannot be left empty.

CHECK constraint (Price > 0) means the Price attribute must contain a value strictly greater than zero.

The UNIFORM table has UCode as its primary key and UName as NOT NULL. The COST table has a composite primary key on (UCode, Size) and a constraint that Price > 0.


(a) Insertions into UNIFORM Relation

(i) (7, Handkerchief, NULL)

This tuple can be inserted.

  • UCode = 7 is unique (not already in the table), satisfying the primary key constraint.
  • UName = 'Handkerchief' is not NULL, satisfying the NOT NULL constraint.
  • UColor = NULL is allowed because UColor has no NOT NULL constraint.

All constraints are satisfied.

(ii) (4, Ribbon, Red)

This tuple cannot be inserted.

  • UCode = 4 already exists in the UNIFORM table (the row for 'Tie').
  • Primary keys must be unique, so inserting another row with UCode = 4 violates the primary key constraint.
Watch out

A common mistake is thinking you can update the primary key by inserting a new row with the same key value. Primary keys are immutable identifiers — if you want to change data for UCode = 4, you must use an UPDATE statement, not INSERT.

(iii) (8, NULL, White)

This tuple cannot be inserted.

  • UCode = 8 is unique, which is fine for the primary key.
  • UName = NULL violates the NOT NULL constraint on UName.

Even though UCode is valid, the NOT NULL constraint on UName prevents this insertion.


(b) Insertions into COST Relation

(i) (7, S, 0)

This tuple cannot be inserted for two reasons:

  1. Foreign key violation (implicit): Although not explicitly stated in the schema diagram, UCode in COST logically references UCode in UNIFORM. Since UCode = 7 does not exist in UNIFORM (we established in part (a)(i) that it could be inserted but hasn't been yet), this would violate referential integrity if a foreign key constraint is enforced.

  2. CHECK constraint violation: Price = 0 violates the constraint Price > 0. The price must be strictly greater than zero. …

Unlock everything free for 14 days

  • Full step-by-step solutions
  • Concept-first explanations
  • Methods, shortcuts & mistakes
  • PYQ mapping + timed mock tests

Full access for 14 days. No credit card required.