Posts

frontend-backend-database

  How it works (step by step) Frontend sends a request GET /api/animals Node.js backend receives the request router.get('/', (req, res) => { ... }); Node.js executes an SQL query SELECT * FROM animals; Database returns data Node.js sends JSON back to frontend Example: Node.js SQL Query (READ) router.get('/animals', (req, res) => {   const sql = 'SELECT * FROM animals';     db.query(sql, (err, results) => {     if (err) {       return res.status(500).json({ error: err.message });     }     res.json(results);   }); }); What’s happening here? Part Meaning router.get() REST API endpoint SELECT * FROM animals SQL query db.query() Node.js sends SQL to MySQL res.json(results) Data return...

npm_1

 Absolutely 👍 Below are viva / exam questions with clear, concise model answers . These are written in exam-safe language , easy to memorize, and strong enough to score full marks. 🔹 Section A: Basic Viva Questions (with Model Answers) 1. What is npm and why is it used in Node.js? Answer: npm (Node Package Manager) is used to install, manage, and share external libraries required for Node.js applications. 2. What does npm init -y do? Answer: It initializes a Node.js project and automatically creates a package.json file with default values. 3. Which file is created when npm init -y is executed? Answer: A package.json file is created. 4. What information is stored in the package.json file? Answer: It stores project metadata such as name, version, scripts, dependencies, and entry file. 5. What is the purpose of the dependencies section in package.json ? Answer: It lists all external packages required for the application to run. 6. Why do we use npm install ? Answer: To download...

Database_1

DATABASE & TABLE CONCEPTS MCQ 1: Purpose of CREATE DATABASE What is the purpose of the following command? CREATE DATABASE IF NOT EXISTS animaldb; A. Creates a new database named animaldb only if it does not already exist B. Deletes the existing database named animaldb ✅ Correct Answer: A MCQ 2: Purpose of USE What does the USE animaldb; command do? A. Deletes the animaldb database B. Selects animaldb as the active database for subsequent queries ✅ Correct Answer: B MCQ 3: Purpose of DROP TABLE IF EXISTS Why is this command used before creating a table? DROP TABLE IF EXISTS animals; A. To remove the table if it already exists and avoid errors B. To permanently lock the table for editing ✅ Correct Answer: A MCQ 4: AUTO_INCREMENT and PRIMARY KEY What is the role of id INT AUTO_INCREMENT PRIMARY KEY? A. Automatically generates a unique identifier for each record B. Allows duplicate values in the id column ✅ Correct Answer: A MCQ 5: NOT NULL Constraint What...