Welcome to Database From Scratch! This repository is your go-to resource for understanding the fundamentals of Database Management Systems (DBMS), Relational Databases (RDBMS), and mastering SQL commands using MySQL.
Whether you're taking your first steps into data management or brushing up on standard queries, you'll find everything organized into easy-to-follow Theory and Practical guides.
Dive deep into core concepts and terminology:
- Theory 01: DBMS vs. RDBMS, intro to SQL and MySQL, Database Objects, and Data Definition Language (DDL).
- Theory 02: Deep dive into DML (Data Manipulation), DQL (Data Query), TCL (Transaction Control), and DCL (Data Control Language).
- Theory 03: CREATE TABLE AS SELECT (
CTAS),INSERTstatements, and introduction to Primary Keys. - Theory 04: Composite Primary Keys,
AUTO_INCREMENTproperty, and default starting values. - Theory 05: MySQL Advanced Concepts,
INSERT IGNORE,ON DUPLICATE KEY UPDATE, andTRUNCATEcommand. - Theory 06:
DROPvsTRUNCATE, and comprehensiveALTER TABLEoperations (Add, Drop, Modify, Change columns). - Theory 07: Data Types in MySQL (Numeric, Decimal, String, Enum, Set).
- Theory 08: Date and Time Data Types in MySQL.
- Theory 09:
SELECTCommand in MySQL. - Theory 10: Query Filtering and Sorting (
IS NULL,IS NOT NULL,ORDER BY, Operator Precedence). - Theory 11:
ORDER BYwithDISTINCT,LIMIT,OFFSET, and Introduction toUPDATE. - Theory 12:
UPDATE,CASEStatements &UPDATEwithLIMIT. - Theory 13:
DELETEcommand,TRUNCATEvsDELETE,DELETEvsDROP, and TCL (COMMIT,ROLLBACK). - Theory 14:
SAVEPOINT,RELEASE SAVEPOINT,AUTO COMMIT, and difference betweenAUTOCOMMITandCOMMIT. - Theory 15: Constraints (Domain Integrity) -
NOT NULL,UNIQUE, andCHECK. - Theory 16: Naming Constraints,
DEFAULTConstraint, andDEFAULTwith Datetime. - Theory 17: SQL Functions, Single Row (Scalar) vs Aggregate Functions, and String Functions.
Get your hands dirty with real SQL queries and commands:
- Practical 01: MySQL basic commands —
SELECT,VERSION(),NOW(), user info, math functions, and showing databases. - Practical 02: Creating databases and tables, dropping schemas, inserting data, Primary Keys, and cloning tables with
CTAS. - Practical 03: Deep dive into creating Primary Keys during table creation and using
ALTER. - Practical 04: Working with Composite Primary Keys,
AUTO_INCREMENT, starting values, andSQL_MODE. - Practical 05: Using
INSERT IGNORE,ON DUPLICATE KEY UPDATE,SHOW CREATE TABLE, andTRUNCATE. - Practical 06: Dropping tables/columns, renaming, and exploring
ALTER TABLEcapabilities. - Practical 07: Working with various Data Types, including Numeric (TINYINT, DECIMAL) and String (TEXT, ENUM, SET).
- Practical 08: Working with Date and Time Data Types.
- Practical 09: Fetching data using the
SELECTcommand. - Practical 10: Query Filtering and Sorting (
IS NULL,IS NOT NULL,ORDER BY). - Practical 11:
ORDER BYwithDISTINCT,LIMIT,OFFSET, andUPDATEstatements. - Practical 12: Using
UPDATEwithCASEStatements andLIMIT. - Practical 13: Practicing
DELETEcommand and TCL (COMMIT,ROLLBACK). - Practical 14: Practicing
SAVEPOINT,RELEASE SAVEPOINT, andAUTO COMMIT. - Practical 15: Working with Constraints (
NOT NULL,UNIQUE, andCHECK). - Practical 16: Using Named Constraints,
DEFAULTconstraint, and tracking time withCURRENT_TIMESTAMP. - Practical 17: Using String Functions such as
UPPER,LOWER,LENGTH,CONCAT, andSUBSTRING.
Test your knowledge with hands-on practice problems:
- Assignments & Solutions: Practical assignment questions with their corresponding answers and solution screenshots.
- Install MySQL: Ensure you have MySQL installed on your system.
- Connect to MySQL:
mysql -u root -p
- Run the Commands: Pick a practical file and start practicing the commands directly in your MySQL monitor.
- DDL:
CREATE,ALTER,DROP(Structure matters!) - DML:
INSERT,UPDATE,DELETE(Manipulate your data.) - DQL:
SELECT(Query your data efficiently.) - TCL:
COMMIT,ROLLBACK(Control your transactions.)
- MySQL Command Line Client
- VS Code or any text editor
Built with 💙 for data enthusiasts everywhere.
