Unit 3 Mindmap: RDBMS Foundations & MySQL SQL-99 (15 Marks)
Interactive high-yield mindmap uniting Chapter 7 relational theory and Chapter 8 MySQL commands.
- File vs DBMS: Solves redundancy, inconsistency, isolation, atomicity & concurrent access issues
- Terms: Relation (Table), Tuple (Row), Attribute (Column), Domain (allowed values), Degree (#cols), Cardinality (#rows)
- Entity: Entity Type (schema definition) vs Entity Instance (one specific row)
- Keys: Candidate Key → chosen Primary Key + Alternate Keys; Composite Key (
STREAM+ROLL); Foreign Key (referential link) - Cardinality: 1:1, 1:M, M:1, M:M relationships
- E.F. Codd (1970): Relational Model pioneer & 12 Rules (Rule 0 Foundation .. Rule 12 Non-Subversion)
- CHAR(n): Fixed length (max 255), static pad, 50% faster for fixed codes
- VARCHAR(n): Variable length (max 65,535 row-shared), dynamic + length prefix
- Open Source vs Commercial: MySQL, PostgreSQL, Enterprise DB vs Oracle, IBM DB2, SQL Server
- 5 Mobile DBs: BerkeleyDB, Couchbase Lite, LevelDB, SQLite, UnQLite
- SQL Evolution: IBM SEQUEL (1970s Chamberlin/Boyce) → Oracle V2 (1979) → ANSI SQL (1986) / SQL-99; MySQL AB (1994/95)
- 3 Components: Server (
mysqld), Clients (mysql), Client Library - Sub-languages: DDL (CREATE/ALTER/DROP), DML (SELECT/INSERT/UPDATE/DELETE), TCL, DCL
- Types: TINYINT..BIGINT, FLOAT/DOUBLE/DECIMAL; CHAR..LONGTEXT; DATE/TIME/DATETIME/YEAR
- 6 Constraints: NOT NULL, UNIQUE, PRIMARY KEY, FOREIGN KEY, DEFAULT, CHECK
- NULL Rule: Arithmetic with NULL = NULL; filter with
IS NULL(never= NULL); Comments:--,#,/* */
- Clauses:
DISTINCT, Aliases (AS),WHERE,BETWEEN,IN,ORDER BY ASC/DESC - LIKE Wildcards:
%(0 or more chars) vs_(exactly 1 char) - Division & Mod:
9 / 2 = 4.5vs9 DIV 2 = 4;%orMOD
Data vs Information: Raw unorganized facts (e.g., "88, Aditya") are Data; processed meaningful output is Information. A DBMS manages interrelated collections of data and overcomes traditional flat-file drawbacks: data redundancy, inconsistency, difficulty in accessing data, data isolation, integrity violations, atomicity failures, concurrent access anomalies, and weak security.
7.1 E.F. Codd's 1970 Relational Model & 12 Rules Summary
Dr. Edgar F. Codd published the relational model in 1970 (IBM) and defined Codd's 12 Rules (numbered 0–12) specifying what makes a database truly relational: Rule 0 (Foundation), Rule 1 (Information — all data in tables), Rule 2 (Guaranteed Access via table+PK+column), Rule 3 (Systematic treatment of NULL), Rule 4 (Active online catalog), Rule 5 (Comprehensive SQL sublanguage), Rule 6 (View updating), Rule 7 (Set-level Insert/Update/Delete), Rules 8–10 (Physical, Logical & Integrity Independence), Rule 11 (Distribution Independence), Rule 12 (Non-Subversion).
7.2 4 Data Type Classes, CHAR vs VARCHAR & Open Source / Mobile DBs
| Feature | CHAR(n) |
VARCHAR(n) |
|---|---|---|
| Storage Length | Fixed length (0 to 255 bytes) | Variable length (1 to 65,535 bytes shared in row) |
| Padding Behavior | Pads shorter strings with trailing spaces to fit n | Stores exact characters + 1 or 2 length-prefix bytes |
| Speed vs Space | Static allocation → up to 50% faster search | Dynamic allocation → saves disk space |
| Best Textbook Use | Fixed-width codes (PIN code, Gender M/F, Flag Y/N) | Variable-length names, addresses, descriptions |
- Commercial Proprietary: Oracle Database, IBM DB2, Microsoft SQL Server, Sybase.
- Open Source RDBMS: MySQL, PostgreSQL, Enterprise DB (textbook Ch 7 MCQ answer!), MariaDB, Firebird.
- Berkeley DB: Embedded key-value (AGPL license).
- Couchbase Lite: Embedded NoSQL JSON sync (Apache).
- LevelDB: Fast key-value store (BSD license).
- SQLite: Serverless ACID SQL DB (Public Domain).
- UnQLite: Self-contained document/KV engine (BSD-2).
History: Structured Query Language began as SEQUEL at IBM in the 1970s (Donald D. Chamberlin, Raymond F. Boyce, Messerly), commercialized as Oracle V2 (1979), standardized by ANSI (1986) and ISO (SQL-99). MySQL was founded by MySQL AB (Sweden, 1994/1995; named after co-founder Michael Widenius's daughter My).
8.1 MySQL Data Types, Identifiers (Max 30 Chars) & 6 Constraints
- Numeric:
TINYINT(1B),SMALLINT(2B),MEDIUMINT(3B),INT(4B),BIGINT(8B),FLOAT(M,D),DOUBLE,DECIMAL(M,D). - String:
CHAR(n),VARCHAR(n),TINYTEXT/TEXT/MEDIUMTEXT/LONGTEXT,BLOB. - Date/Time:
DATE('YYYY-MM-DD'),TIME('HH:MM:SS'),DATETIME,TIMESTAMP,YEAR.
NOT NULL(forbids empty/missing value) &UNIQUE(no duplicates, allows NULLs).PRIMARY KEY(=NOT NULL+UNIQUE).FOREIGN KEY ... REFERENCES(links parent PK).DEFAULT val(fallback value) &CHECK (cond).- 3 SQL Comment Styles:
-- comment(space after--!),# comment,/* multi-line */.
8.2 Essential MySQL Clauses, Operators, NULL Rules & Precedence
LIKE Wildcards & NULL Handling.-- 1. Create Database 'LOAN' and table 'LoanAccount' (Ch 8 Long Q3) CREATE DATABASE LOAN; USE LOAN; CREATE TABLE LoanAccount ( AcctNo INT PRIMARY KEY, Cust_Name VARCHAR(40) NOT NULL, LoanAmount INT, IntRate DECIMAL(5,2), Instalments INT, Start_Date DATE ); INSERT INTO LoanAccount VALUES (1, 'Shreyas Pradhan', 300000, 12.00, 36, '2009-07-19'); INSERT INTO LoanAccount (AcctNo, Cust_Name, LoanAmount, Instalments) VALUES (3, 'A A Dumpy', 300000, 36); -- Note Q5: Any field omitted in INSERT INTO defaults to NULL (unless DEFAULT defined). -- 2. Display details of all loans / selective columns / filter Instalments < 40 SELECT * FROM LoanAccount; SELECT AcctNo, Cust_Name, LoanAmount FROM LoanAccount; SELECT * FROM LoanAccount WHERE Instalments < 40; -- 3. Short Q2 Essentials (Employee / Student Queries) SHOW DATABASES; DESC LoanAccount; -- Show table structure ALTER TABLE Employee ADD Email VARCHAR(60); -- Add column ALTER TABLE Employee CHANGE EmpName Name VARCHAR(40); -- Rename column SELECT DISTINCT Dept FROM Employee; -- Unique departments SELECT * FROM Employee WHERE Name LIKE BINARY 'd%'; -- Case-sensitive starts with 'd' (not 'D') SELECT * FROM Employee WHERE Name LIKE '%s'; -- Ends with 's' SELECT EmpCode, Name, Salary FROM Employee ORDER BY Salary DESC; UPDATE Student SET Name='Duani' WHERE Name='Dunia'; -- (See Ex Q11) DELETE FROM Student WHERE marks < 33; DROP TABLE LoanAccount; -- Deletes structure + data
8.3 Expected MySQL Query Output Tables (Exam Output-Prediction Practice)
SELECT AcctNo, Cust_Name, IntRate, Instalments FROM LoanAccount WHERE Instalments < 40; | |||
|---|---|---|---|
| AcctNo | Cust_Name | IntRate | Instalments |
| 1 | Shreyas Pradhan | 12.00 | 36 |
| 3 | A A Dumpy | NULL | 36 |
| 5 | Rakesh Bhoi | 12.50 | 36 |
SELECT AcctNo, LoanAmount * IntRate / 100 AS YearlyInt FROM LoanAccount WHERE AcctNo IN (1,3,4); | ||
|---|---|---|
| AcctNo | YearlyInt | Why? |
| 1 | 36000.00 | 300000 × 12.00 / 100 |
| 3 | NULL | Anything × NULL = NULL! |
| 4 | 100000.00 | 800000 × 12.50 / 100 |
Complete Solved Textbook Exercises — Chapters 7 & 8
- Q1–Q7 Key Concepts: Tuple = Row; Attribute = Column; Degree = number of columns; Cardinality = number of rows; Primary Key uniquely identifies every tuple without
NULL; Foreign Key links child table column to parent table Primary Key. - Q8 (Open Source DBMS in textbook list): Enterprise DB (alongside MySQL & PostgreSQL, vs Oracle/DB2/SQL Server).
- CHAR vs VARCHAR: Write exact byte limits (
255vs65,535), padding vs length-prefix, and static 50% speed advantage.
INoperator: (a) checks a value in a list (e.g.,WHERE city IN ('Cuttack','Puri')).DROP DATABASE db;: removes a Database permanently.INSERT INTO: (c) inserts new row into a table.- Sort output rows: (d)
ORDER BY. - Change
'Dunia'to'Duani':UPDATE Student SET Name='Duani' WHERE Name='Dunia';. - Delete rows below marks threshold:
DELETE FROM Student WHERE marks < 33;(textbook print shows 351 typo in options, statement syntax usesDELETE FROM ... WHERE). - DELETE vs DROP:
DELETEis a DML command removing selected/all rows while keeping table schema (can useWHERE&ROLLBACK);DROPis a DDL command destroying the entire table definition + data permanently. - What happens on arithmetic with NULL? Any arithmetic operation involving
NULLalways returnsNULL(never0).
Discussion & Queries 0
Post a Comment or Doubt