Skip to content
Activities · Activity 9.4

Q.Create the other two relations GUARDIAN and ATTENDANCE as per data types given in Table 9.4 and 9.5 respectively, and view their structures. Do not add any constraint in these two tables.
[Table: Table 9.4 (relation GUARDIAN) data types — GUID: CHAR(12); GName: VARCHAR(20); GPhone: CHAR(10); GAddress: VARCHAR(30). Table 9.5 (relation ATTENDANCE) data types — AttendanceDate: DATE; RollNumber: INT; AttendanceStatus: CHAR(1).]

West Bengal WbchseTextbookSubjective· 3mImportance★★★★★est
8% · 8/95 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 solution demonstrates how to create two SQL tables, GUARDIAN and ATTENDANCE, using the CREATE TABLE statement with specified column names and data types, and then how to view their structures using the DESCRIBE command.

In SQL, before you can store any data, you must first define the structure of your tables. This is done using the CREATE TABLE statement. It's like drawing a blueprint for your data, specifying what kind of information each column will hold. Once a table is created, you often need to inspect its structure to confirm the column names, data types, and any applied constraints. The DESCRIBE command (or DESC) is used for this purpose.

Creating the GUARDIAN Table

The GUARDIAN table needs to store information about guardians, including a unique ID, name, phone number, and address. Each piece of information requires a specific data type to ensure data integrity and efficient storage.

  • GUID: CHAR(12) is chosen for a fixed-length guardian ID, ensuring consistency.
  • GName: VARCHAR(20) is suitable for names, allowing variable length up to 20 characters.
  • GPhone: CHAR(10) is used for phone numbers, assuming a fixed 10-digit format.
  • GAddress: VARCHAR(30) allows for variable-length addresses up to 30 characters.
CREATE TABLE GUARDIAN (
    GUID CHAR(12),
    GName VARCHAR(20),
    GPhone CHAR(10),
    GAddress VARCHAR(30)
);

Creating the ATTENDANCE Table

The ATTENDANCE table will record attendance details, including the date, the student's roll number, and their attendance status.

  • AttendanceDate: DATE is the appropriate data type for storing calendar dates.
  • RollNumber: INT is used for integer roll numbers.
  • AttendanceStatus: CHAR(1) is ideal for a single-character status (e.g., 'P' for Present, 'A' for Absent).
CREATE TABLE ATTENDANCE (
    AttendanceDate DATE,
    RollNumber INT,
    AttendanceStatus CHAR(1)
);

Viewing Table Structures

After creating the tables, it's good practice to verify their structures. The DESCRIBE command (or its shorthand DESC) is used to display the column names, their data types, and other attributes for a given table.

Structure of GUARDIAN Table
DESCRIBE GUARDIAN;

Expected Output:

FieldTypeNullKeyDefaultExtra
GUIDchar(12)YESNULL
GNamevarchar(20)YESNULL
GPhonechar(10)YESNULL

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.