0% found this document useful (0 votes)
2 views2 pages

Day1 Database SQL Basics

The document provides an overview of databases and SQL basics, including definitions of DBMS, RDBMS, and NoSQL, as well as key concepts such as primary keys, foreign keys, and the ER model. It outlines fundamental SQL commands for creating, inserting, selecting, updating, and deleting data, along with filtering, grouping, and joining tables. Additionally, it introduces normalization principles to ensure data integrity.

Uploaded by

ibrahimaltaf1118
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views2 pages

Day1 Database SQL Basics

The document provides an overview of databases and SQL basics, including definitions of DBMS, RDBMS, and NoSQL, as well as key concepts such as primary keys, foreign keys, and the ER model. It outlines fundamental SQL commands for creating, inserting, selecting, updating, and deleting data, along with filtering, grouping, and joining tables. Additionally, it introduces normalization principles to ensure data integrity.

Uploaded by

ibrahimaltaf1118
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

■ Day 1 – Databases & SQL Basics

1. What is DBMS?
• DBMS (Database Management System): Software to store, organize, and manage data.
• RDBMS (Relational DBMS): Uses tables (rows & columns). Example: MySQL, PostgreSQL.
• NoSQL: Works with documents, key-value, graph data. Example: MongoDB.
• Why DBMS? Avoids data redundancy, ensures consistency, provides security & backup,
enables multi-user access.

2. Keys in Database
• Primary Key: Uniquely identifies a record (e.g., student_id).
• Foreign Key: Refers to primary key in another table (creates relation).
• Candidate Key: Possible choices for primary key.
• Composite Key: Two or more attributes combined to uniquely identify.

3. ER Model Basics
• Entity: Object in database (e.g., Student, Course).
• Attribute: Property of entity (e.g., Name, Age).
• Relationship: Connection between entities (e.g., Student enrolls in Course).

4. SQL Basics
• CREATE TABLE Students (student_id INT PRIMARY KEY, name VARCHAR(50), age INT);
• INSERT INTO Students VALUES (1, 'Ali', 20);
• INSERT INTO Students VALUES (2, 'Sara', 22);
• SELECT * FROM Students;
• SELECT name FROM Students WHERE age > 20;
• UPDATE Students SET age = 23 WHERE student_id = 2;
• DELETE FROM Students WHERE student_id = 1;

5. Filtering & Grouping


• SELECT age, COUNT(*) FROM Students GROUP BY age HAVING COUNT(*) > 1;
• WHERE → row-level filter
• GROUP BY → groups rows
• HAVING → filter groups

6. Joins
• INNER JOIN: Returns matching rows.
• LEFT JOIN: All from left + matching right.
• RIGHT JOIN: All from right + matching left.
• FULL JOIN: All rows from both.
• Example: SELECT [Link], c.course_name FROM Students s INNER JOIN Courses c ON
s.student_id = c.student_id;
7. Normalization
• 1NF: Atomic values (no repeating groups).
• 2NF: 1NF + no partial dependency.
• 3NF: 2NF + no transitive dependency.

You might also like