- What is the difference between SQL and MySQL?
- What do you mean by DBMS? What are its different types?
- What are the types of joins in SQL? Give an example for each one.
- What is a Primary key?
- What are the different operators available in SQL?
- What is the need for group functions in SQL?
- What is a Relationship and what are they?
Please discuss these questions with your partners and post your answers as a comment on this gist when you are finished.
**### Team Group:
Lubna Abdelkhaliq
Nour Kayyali
Wajd Al-Kayyali
Ammar Kolko
Q0- What is the difference between SQL and MySQL?
SQL is a query programming language that manages RDBMS.
MySQL is a relational database management system that uses SQL.
SQL is primarily used to query and operate database systems.
MySQL allows you to handle, store, modify and delete data and store data in an organized way
Q1- What do you mean by DBMS? What are its different types?
A database management system (DBMS) is a computer program designed to manage a large amount of structured data, and run operations on the desired data requested by the users
There are three main types of DBMS data models: relational, network, and hierarchical.
Relational data model: Data is organized as logically independent tables.
Network data model: All entities are organized in graphical representations.
Hierarchical data model: Data is organized into a tree-like structure.
Q2- What are the types of joins in SQL? Give an example for each one.
Purpose: Retrieves records that have matching values in both tables.
Example: SELECT customers.customer_id, orders.order_date
FROM customers
INNER JOIN orders
ON customers.customer_id = orders.customer_id;
Result: Returns only customers who have placed orders, with their corresponding order dates.
Purpose: Retrieves all records from the left table, and the matched records from the right table. If there's no match in the right table, NULL values are returned for those columns.
Example :SELECT customers.customer_id, orders.order_date
FROM customers
LEFT JOIN orders
ON customers.customer_id = orders.customer_id;
Result: Returns all customers, including those without orders (showing NULL for order_date).
3)Right Outer Join:
Purpose: Retrieves all records from the right table, and the matched records from the left table. If there's no match in the left table, NULL values are returned for those columns.
Example :SELECT customers.customer_id, orders.order_date
FROM customers
RIGHT JOIN orders
ON customers.customer_id = orders.customer_id;
Result: Returns all orders, including those without a corresponding customer (showing NULL for customer_id).
Purpose: Retrieves all records from both tables, including unmatched rows, filling in NULL values where there's no match.
Example :SELECT customers.customer_id, orders.order_date
FROM customers
FULL JOIN orders
ON customers.customer_id = orders.customer_id;
Result: Returns all customers and all orders, even if they don't have a corresponding match in the other table.
Q3- What is a Primary key?
A primary key is a special column or set of columns in a database table that uniquely identifies each row in that table
***key characteristics of primary keys:
-Uniqueness: Each value in the primary key column(s) must be unique within the table. This means no two rows can have the same primary key value.
-Not Null: Primary key columns cannot contain null values. They must always have a value to ensure they can uniquely identify each row.
-Single Primary Key per Table: A table can have only one primary key.
***Purpose of Primary Keys:
Preventing Duplicates, Creating Relationships
Q4- What are the different operators available in SQL?
Logical // Compound // Comparison // Bitwise // Arithmetic https://www.w3schools.com/sql/sql_operators.asp
Q5- What is the need for group functions in SQL?
In SQL, the GROUPING function is a very useful tool when dealing with complex queries that involve grouping sets, rollup, and cube operations. Group functions are built-in SQL functions that operate on groups of rows and return one value for the entire group. These functions are: COUNT, MAX, MIN, AVG, SUM, DISTINCT
Q6- What is a Relationship and what are they?
In SQL, a relationship refers to a connection between two tables based on a common column. It is established using foreign keys, which link the data in one table to the data in another. This helps maintain data integrity and enables queries that involve data from multiple tables. There are different types of relationships, such as one-to-one, one-to-many, and many-to-many, each serving specific data modeling needs.