Skip to content
Long Answer Questions · Q12

Q.Describe, with the steps and short code, how a customer-record database application is developed by bringing the front-end and back-end together. Include creating the table and the actions to add and search a customer.

ChseodishaTextbookSubjectiveImportance★★★★★est
100% · 12/12 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 →

A small customer-record application shows how the front-end, back-end and connectivity combine. The development follows a clear path.

Step 1 — Analyse and design. Decide the data and the actions. For each customer we need an identity number, a name, a city and a phone; the user must be able to add a customer and search for one.

Step 2 — Build the back-end (the table). Create the table, choosing a data type for each column and a primary key to identify each row:

CREATE TABLE Customer (
    CustID   INTEGER      PRIMARY KEY,
    Name     VARCHAR(50)  NOT NULL,
    City     VARCHAR(30),
    Phone    VARCHAR(15)
);

Step 3 — Build the front-end (the form). Design a form with a label and a text box for each field (CustID, Name, City, Phone) and two buttons — Add and Search.

Step 4 — Connect the two (event handlers). For each button, write a handler that opens a connection, runs the right SQL and shows the result.

Add a customer — after validating the boxes:

WHEN Add button is clicked:
    validate that CustID and Name are not empty
    open connection to database
    execute:  INSERT INTO Customer (CustID, Name, City, Phone)
              VALUES (:id, :name, :city, :phone)
    show message "Customer added"
    close connection

Search a customer by ID:

WHEN Search button is clicked:
    open connection to database
    result = execute:  SELECT Name, City, Phone FROM Customer WHERE CustID = :id
    IF result has a row THEN put its values into the Name, City, Phone boxes
    ELSE show message "No such customer"
    close connection

Step 5 — Test. Add a few customers and confirm they are stored; search an existing and a non-existing ID; and try adding a blank name to confirm validation refuses it. …

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.