Class 12 Computer Science Notes
Based on Sumita Arora's Textbook
Computer Network - 2
Computer Network - 2:
Definition and Purpose:
- Computer networks connect multiple computers, enabling data exchange.
- Types include LAN, WAN, MAN, etc., each suitable for different scopes of use.
Network Topologies:
- Bus: Single cable connecting all nodes; one fault affects the whole network.
- Star: Central hub connects all nodes, providing better fault tolerance.
- Ring: Nodes form a circular path; data travels in one direction.
- Mesh: Each node connects to multiple nodes, enhancing redundancy.
- Hybrid: Combines different topologies, improving versatility.
Network Protocols:
- TCP/IP: Fundamental suite for internet communication.
- HTTP/HTTPS: Used for web browsing, HTTPS adds encryption.
- FTP: File Transfer Protocol for uploading/downloading files.
- SMTP/POP3: Used for sending and receiving emails.
Transmission Media:
- Wired: Coaxial cables, fiber optics provide high speed, but need physical links.
- Wireless: Wi-Fi and Bluetooth offer flexibility, though signal strength can vary.
Network Devices:
- Router: Directs data packets across networks.
- Switch: Connects devices within a single network, handling data traffic.
- Modem: Enables access to the internet by modulating digital signals.
Relational Database
Relational Database:
Introduction to RDBMS:
- RDBMSs organize data in tables and allow relationships between tables.
- Essential for structured storage and retrieval of data.
Database Models:
- Hierarchical: Data organized in a tree-like structure.
- Network: More complex connections, useful for networks.
- Relational: Data stored in tables with columns and rows.
Key Terms:
- Table: Data is organized in rows and columns.
- Record: Single entry in a table.
- Field: Specific attribute (column) in a table.
- Primary Key: Unique identifier for records.
- Foreign Key: Links records across tables.
Advantages of RDBMS:
- Maintains data integrity, reduces redundancy, enables complex queries.
Normal Forms:
- 1NF, 2NF, 3NF: Levels of database normalization to reduce redundancy and dependencies.
Simple Queries in SQL
Simple Queries in SQL:
SQL Basics:
- SQL is used to manage and query relational databases.
- Common SQL commands include SELECT, INSERT, UPDATE, DELETE.
Basic SQL Commands:
- SELECT: Retrieves data from a database.
- FROM: Specifies the table to query.
- WHERE: Filters results based on a condition.
- ORDER BY: Sorts results by specified column.
- DISTINCT: Removes duplicate values from results.
Filtering Data:
- Conditions use operators like =, >, <, AND, OR, NOT to refine searches.
Sorting and Limiting Results:
- ORDER BY organizes data in ascending or descending order.
- LIMIT restricts the number of returned results.
Table Creation and Data Manipulation Commands
Table Creation and Data Manipulation Commands:
Creating Tables:
- CREATE TABLE command initializes a table in the database.
- Syntax: CREATE TABLE table_name (column1 datatype, column2 datatype, ...).
Data Types:
- INT, VARCHAR, DATE, and others specify the nature of each column's data.
Data Manipulation:
- INSERT INTO: Adds new records.
- UPDATE: Modifies existing records.
- DELETE: Removes records from a table.
Altering Tables:
- ALTER TABLE allows adding, modifying, or dropping columns.
Grouping Records, Joins in SQL
Grouping Records, Joins in SQL:
Grouping Records:
- GROUP BY groups rows sharing a common field.
- HAVING applies a condition to groups.
Joins:
- INNER JOIN: Returns records with matching values in both tables.
- LEFT JOIN: Returns all records from the left table and matched records from the right.
- RIGHT JOIN: Returns all records from the right table and matched records from the left.
- FULL JOIN: Returns records when there's a match in one of the tables.
Interface Python with MySQL
Interface Python with MySQL:
Connecting Python to MySQL:
- Python's MySQL connector enables database interactions.
Basic Steps:
1. Install MySQL connector (pip install mysql-connector-python).
2. Import mysql.connector module.
3. Use connect() function with database credentials.
Performing CRUD Operations:
- Cursor object in Python executes SQL commands.
Error Handling:
- Handle exceptions for robust code execution.