Skip to content

Instantly share code, notes, and snippets.

@halitbatur
Created January 2, 2024 13:21
Show Gist options
  • Save halitbatur/5a44d079ac9ba91933039adccb9cfd4f to your computer and use it in GitHub Desktop.
Save halitbatur/5a44d079ac9ba91933039adccb9cfd4f to your computer and use it in GitHub Desktop.
SQL Discussion

SQL discussions

  1. What is the difference between SQL and MySQL?
  2. What do you mean by DBMS? What are its different types?
  3. What are the types of joins in SQL? Give an example for each one.
  4. What is a Primary key?
  5. What are the different operators available in SQL?
  6. What is the need for group functions in SQL?
  7. 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.

@belalninja
Copy link

belalninja commented Jan 4, 2024

Room 5: Belal, Ahmad Shalash, Mo'mena

0. What is the difference between SQL and MySQL?

SQL is a standardized language for managing data in relational databases, while MySQL is a relational database management system that uses SQL to manage data.

The main differences are:

  1. SQL is a query language, MySQL is software
  2. SQL syntax works with many databases, MySQL has some proprietary extensions
  3. SQL is just an interface, MySQL is a database serve

1. What do you mean by DBMS? What are its different types?

DBMS is database management system software for defining, storing, managing, and querying data.

Types:

  1. Relational (MySQL)
  2. NoSQL (MongoDB)
  3. Object-oriented
  4. Network
  5. Hierarchical

2. What are the types of joins in SQL? Give an example for each one.

image

  1. Inner join SELECT * FROM Table1 INNER JOIN Table2 ON Table1.id = Table2.table1_id
  2. Left join SELECT * FROM Table1 LEFT JOIN Table2 ON Table1.id = Table2.table1_id
  3. Right join SELECT * FROM Table1 RIGHT JOIN Table2 ON Table1.id = Table2.table1_id
  4. Full join SELECT * FROM Table1 FULL OUTER JOIN Table2 ON Table1.id = Table2.table1_id
  5. Self join SELECT * FROM Table1 T1 JOIN Table1 T2 ON T1.id = T2.table1_id

3. What is a Primary key?

it's a column in a relational database that contains unique identifiers/key for each item/value/row of data in the database

image

4. What are the different operators available in SQL?

SQL operator is a special word or character used to perform tasks. There are six types of SQL operators:

  1. Arithmetic operators: such as + (Addition), - (Subtraction)
  2. Bitwise Operators: such as & (and), | (or)
  3. Comparison Operators: such as = (equal), > (Greater than)
  4. Compound Operators: such as += (Add equals), -= (Subtract equals)
  5. Logical Operators: such as ALL (TRUE if all of the subquery values meet the condition), AND (TRUE if all the conditions separated by AND is TRUE)
  6. String Operators: such as + (String concatenation), += (String concatenation assignment)

5. What is the need for group functions in SQL?

Group functions in SQL are used to perform operations on a set of rows and return a single value. They are used to aggregate, calculate, and summarize data from multiple rows into a single result.

Group functions are useful for analyzing and summarizing data in a database.

6. What is a Relationship and what are they?

In the context of databases, a relationship refers to the connection between two or more tables. Relationships are used to link data in different tables together, allowing you to access and manipulate related data in a structured and organized way.

types of relationships:

  • Many-to-many
    image
  • One-to-One
    image
  • One-to-Many
    image

@MonaAlHajEid
Copy link

Team Members: Muna Al Haj Eid, Mohammed El amarieh, Mohammed Karbejha, Hadeel obeid, Omar Masud.

  1. SQL is a language used to manage data stored in relational database management systems.
    MySQL is a relational database management system that uses SQL as its standard language for managing data.

1- DBMS stands for Database Management System. It's like a digital filing cabinet that keeps your data organized and easily accessible. There are different types like relational (tables & rows), NoSQL (flexible for unstructured data), and object-oriented (data & functions combined).
Choosing the right one depends on your data needs and complexity.

  • INNER JOIN: Returns only the rows that have matching values in both tables. For example, consider two tables Orders and Customers. The following SQL statement returns all orders with corresponding customer information.
  • LEFT OUTER JOIN: Returns all the rows from the left table and the matched rows from the right table. If there is no match, NULL values are returned for the right table. For example, consider two tables Orders and Customers. The following SQL statement returns all orders with corresponding customer information. If there is no matching customer information, NULL values are returned.
  • RIGHT OUTER JOIN: Returns all the rows from the right table and the matched rows from the left table. If there is no match, NULL values are returned for the left table. For example, consider two tables Orders and Customers. The following SQL statement returns all customers with corresponding order information. If there is no matching order information, NULL values are returned.
  • FULL OUTER JOIN: Returns all the rows from both tables. If there is no match, NULL values are returned for the missing table. For example, consider two tables Orders and Customers. The following SQL statement returns all orders and customers with corresponding information. If there is no matching information, NULL values are returned.
  1. Primary Key: A primary key is a unique identifier for a record in a database table. It ensures each row in the table is uniquely identifiable and helps in establishing relationships between different tables in a database.

  2. SQL Operators: Different operators available in SQL include:

  • Comparison operators: (=, <>, <, >, <=, >=)
  • Logical operators: (AND, OR, NOT)
  • Arithmetic operators: (+, -, *, /)
  • Concatenation operator: (|| in some SQL versions)
  • IN, BETWEEN, LIKE, EXISTS, IS NULL, etc.
  • They help you summarize large datasets efficiently, such as counting items, calculating totals, finding averages, and identifying extremes.
  • They allow you to categorize and analyze data by grouping it, which helps you explore relationships, discover patterns, and make informed decisions.
  • They are crucial for generating reports and making data-driven decisions by creating summaries of key metrics.
  • They also play a role in exploring and understanding data by analyzing its distribution and detecting outliers.
  • In machine learning, they can be used to prepare data by creating new features through aggregation.
  1. In SQL, "relationship" has two sides:
  2. Table Connections: Links data across tables using foreign keys and joins. Three main types:
    One-to-One: One row in one table relates to one row in another (e.g., customer to email).
    One-to-Many: One row in one table relates to many rows in another (e.g., customer to orders).
    Many-to-Many: Many rows in both tables can relate to each other (e.g., actors to movies).
  3. Data Insights: Uncovering connections within data using functions and joins. Helpful for exploring patterns and trends.

@fedabaqain
Copy link

Team : Mohammad,Diala,Yassin,malak,feda
Q0: SQL is a programming language you can use to store and process information in a relational database. MySQL is the most widely adopted open-source relational database. Both technologies work together so that you can store and process data in structured tables with rows and columns. MySQL is the underlying technology that stores the data, while SQL is the language you use to read, modify, and delete that data.

Q1- DBMS : Database Management Systems is a collection of programs used for managing data and simultaneously it supports different types of users to create, manage, retrieve, update and store information.
Relational database:is a system where data is organized in two-dimensional tables using rows and columns.
Object Oriented Database: It is a system where information or data is represented in the form of objects which is used in object-oriented programming.
Hierarchical Database: It is a system where the data elements have a one to many relationship (1: N). Here data is organized like a tree which is similar to a folder structure in your computer system.

Network database is a system where the data elements maintain one to one relationship (1: 1) or many to many relationship (N: N).It also has a hierarchical structure, but the data is organized like a graph and it is allowed to have more than one parent for one child record.

Q2:(INNER) JOIN: Returns records that have matching values in both tables
LEFT (OUTER) JOIN: Returns all records from the left table, and the matched records from the right table
RIGHT (OUTER) JOIN: Returns all records from the right table, and the matched records from the left table
FULL (OUTER) JOIN: Returns all records when there is a match in either left or right table

Q3: the column or columns that contain values that uniquely identify each row in a table.

Q4:1- SQL Arithmetic Operators 2-SQL Bitwise Operators 3-SQL Comparison Operators 4- SQL Compound Operators 5- SQL Logical Operators

Q5: they are built-in SQL functions that operate on groups of rows and return one value for the entire group.COUNT, MAX, MIN, AVG, SUM, DISTINCT

Q6:an association between tables. Those associations create using join statements to retrieve data. It is a condition that exists between two database tables in which one table contains a foreign key that references the primary key of the other tables.
one-to-one.
one-to-many.
many-to-many.

@MohamadSheikhAlshabab
Copy link

Room 6 :

Mohamad Sheikh Alshabab, Najwan, Farah, Lunar

0- SQL is a query programming language that manages RDBMS. MySQL is a relational database management system that uses SQL.

1- DBMS: A database management system (DBMS) is system software for creating and managing databases. A DBMS makes it possible for end users to create, protect, read, update and delete data in a database, It handles tasks like data storage, retrieval, and management.

Types of DBMS:

    1. Relational DBMS (RDBMS): is a system where data is organized in two-dimensional tables using rows and columns, This is one of the most popular data models which is used in industries. It is based on SQL.
    1. Object-Oriented DBMS (OODBMS): It is a system where information or data is represented in the form of objects which is used in object-oriented programming, It is a combination of relational database concepts and object-oriented principles, and it requires less code and is easy to maintain.
    1. Hierarchical DBMS: It is a system where the data elements have a one to many relationship (1: N). Here data is organized like a tree which is similar to a folder structure in your computer system, The hierarchy starts from the root node, connecting all the child nodes to the parent node.
    1. Network DBMS: is a system where the data elements maintain one to one relationship (1: 1) or many to many relationship (N: N).

It also has a hierarchical structure, but the data is organized like a graph and it is allowed to have more than one parent for one child record.

2-

    1. INNER JOIN:

Returns matching rows from both tables.
Example: SELECT * FROM table1 INNER JOIN table2 ON table1.column = table2.column;

    1. LEFT JOIN:

Returns all rows from the left table and matching rows from the right table.
Example: SELECT * FROM table1 LEFT JOIN table2 ON table1.column = table2.column;

    1. RIGHT JOIN:

Returns all rows from the right table and matching rows from the left table.
Example: SELECT * FROM table1 RIGHT JOIN table2 ON table1.column = table2.column;

    1. FULL JOIN:

Returns all rows when there is a match in either table.
Example: SELECT * FROM table1 FULL JOIN table2 ON table1.column = table2.column;

    1. CROSS JOIN:

Returns the Cartesian product of both tables.
Example: SELECT * FROM table1 CROSS JOIN table2;

    1. SELF JOIN:

Joins a table with itself using aliases.
Example: SELECT e1.name, e2.name FROM employees e1 INNER JOIN employees e2 ON e1.manager_id = e2.employee_id;

3- is a column in a relational database table that's distinctive for each record.

4- SQL Arithmetic Operators · SQL Bitwise Operators · SQL Comparison Operators · SQL Compound Operators · SQL Logical Operators

5- Group functions, also known as aggregate functions, are essential in SQL for performing calculations on sets of values and summarizing data in a result set. These functions operate on a group of rows and return a single value for each group. The need for group functions in SQL arises from several reasons:

Summarizing Data:

Group functions allow you to perform calculations on a set of values within a specific group. For example, you can calculate the total sales, average salary, or maximum value for each group.
Statistical Analysis:

SQL group functions provide statistical measures like average, standard deviation, variance, etc., which are useful for analyzing data distributions within groups.
Data Aggregation:

They help in aggregating data from multiple rows into a single result. This is particularly important when working with large datasets where summarizing information is necessary for meaningful analysis.
Reporting:

Group functions are commonly used in generating reports where aggregated data is presented. For instance, you might want to show the total sales for each product category or the average score for each student in a class.
Data Analysis and Business Intelligence:

In the context of data analysis and business intelligence, group functions play a crucial role in extracting meaningful insights from datasets. They enable users to analyze trends, patterns, and summarize key metrics.
Efficiency:

Group functions improve the efficiency of data retrieval and analysis by allowing you to perform calculations directly in the database engine. This reduces the amount of data transferred between the database and the application, leading to better performance.
Combining with GROUP BY Clause:

Group functions are typically used in conjunction with the GROUP BY clause, which divides the result set into groups based on one or more columns. This facilitates the aggregation of data within each group.
Flexibility in Analysis:

Group functions provide flexibility in the type of analysis you can perform, whether it's finding the minimum or maximum value, calculating the average, or counting the number of occurrences within each group.
Commonly used SQL group functions include:

COUNT(): Counts the number of rows in a group.
SUM(): Calculates the sum of values in a group.
AVG(): Calculates the average of values in a group.
MIN(): Finds the minimum value in a group.
MAX(): Finds the maximum value in a group.
In summary, group functions are indispensable in SQL for summarizing, analyzing, and extracting meaningful information from datasets, making them a fundamental aspect of database querying and reporting.

6- Relationships are the established associations between two or more tables. Relationships are based on common fields from more than one table, often involving primary and foreign keys.One-to-One (1:1),One-to-Many (1:N),Many-to-Many (M:N).

@JanaAbuHaltam
Copy link

Jana AbuHaltam, Musab Sakhreyah, Ahmad Mash, Lina Abumahfood ,Rinad Abu Qauod

Q0.SQL is a query programming language . MySQL is a relational database management system that uses SQL.

Q1 (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.types include integer, float, characters, strings, and arrays.

Q2 Different Types of SQL JOINs (INNER) JOIN : Returns records that have matching values in both tables.
LEFT (OUTER) JOIN : Returns all records from the left table, and the matched records from the right table.
RIGHT (OUTER) JOIN : Returns all records from the right table, and the matched records from the left table.

Q3 A primary key is the column or columns that contain values that uniquely identify each row in a table

Q4 1) Arithmetic Operators:

  • (Addition)
  • (Subtraction)
  • (Multiplication)
    / (Division)
    % (Modulus)
  1. Comparison Operators:
    = (Equal to)
    != or <> (Not equal to)
    < (Less than)

(Greater than)
<= (Less than or equal to)
= (Greater than or equal to)

  1. Logical Operators:
    AND (Logical AND)
    OR (Logical OR)
    NOT (Logical NOT)

  2. Bitwise Operators:
    • Perform operations on bit patterns of integer values.
    • Operators: & (bitwise AND), | (bitwise OR), ^ (bitwise XOR), ~ (bitwise NOT), << (left shift), >> (right shift)

  3. String Operators:
    • Manipulate and compare string values.
    • Operators: || (concatenation), LIKE (pattern matching)

  4. Compound Operators:
    • Combine assignment and arithmetic or bitwise operations.
    • Operators: +=, -=, *=, /=, %=, &=, |=, ^=, <<=, >>=

  5. Other Operators:
    • BETWEEN: Checks if a value is within a specified range.
    • IN: Checks if a value is present in a list of values.
    • IS NULL: Checks if a value is null.
    • EXISTS: Checks if a subquery returns any rows.

Q5 1. Summarizing Data
2. Data Analysis
3. Statistical Calculations
4. Data Reporting
5. Performance Optimization
6. Efficient Data Retrieval

Q6 a relationship refers to the connection between two or more tables in a relational database. These relationships define how data in one table is related to data in another table.
Rinad Abu Qauod 6:37 PM
6- a relationship refers to the connection between two or more tables in a relational database. These relationships define how data in one table is related to data in another table.

There are three main types of relationships:
1- One-to-One (1:1) Relationship
2- One-to-Many (1:N) Relationship
3- Many-to-Many (N:N) Relationship

@FarahAlsoqi
Copy link

Q1 SQL is a query language, MySQL is a relational database that uses SQL to query a database
Q2 DBMS Database Management Systems. It is a software system that allows users to store, modify, and extract data from a database.
Types of DBMS:
1-Relational database.
2-Object oriented database.
3-Hierarchical database.
4-Network database.
Q3 A primary key is a field in a database table that uniquely identifies each record in the table.
Q4
Types of SQL operators:
1- comparison operators ( =, <, >, <=, >=, <>)
2- logical operators (AND, OR, NOT)
3- arithmetic operators (+, -, *, /)
4- string operators (LIKE, IN, BETWEEN)
Q5 SQL are used to perform calculations
Q6
Tables Relations in SQL Server:
One-to-One,
One-to-Many,
Many-to-Many,

@Hayder000
Copy link

Team: Hayder, Hakeema, Ramah, Osama

Q0: The difference is SQL is a programming language which MySQL, which is a open-sourced software, uses. SQL is mainly used for storing, manipulating and retrieving data in a RDB, while MySQL is a open source DB management system, That allows managing relational databases,

Q1: DBMS is Database management system software, which 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 different types of DBMS, some of them are: Relation Databases, Object Oriented Databases, Hierarchical Databases, Network Databases.

Q2: The different types of joins are: INNER JOIN, OUTER JOIN, CROSS JOIN, SELF JOIN. Examples of them:
INNER JOIN: Returns only the rows where there is a match in both tables.
SELECT employees.employee_id, employees.employee_name, departments.department_name
FROM employees
INNER JOIN departments ON employees.department_id = departments.department_id;

OUTER JOIN: Returns all rows from the left table (For this example) and the matched rows from the right table. If there is no match, NULL values are returned for columns from the right table.
SELECT customers.customer_id, customers.customer_name, orders.order_id
FROM customers
LEFT JOIN orders ON customers.customer_id = orders.customer_id;

CROSS JOIN: is used to generate the Cartesian product of two tables, creating all possible combinations of rows between them without any specific matching condition.
SELECT students.student_id, students.student_name, subjects.subject_id, subjects.subject_name
FROM students
CROSS JOIN subjects;

SELF JOIN: A self join is used to combine rows within a table, treating it as if it were two separate tables.
SELECT e.employee_name AS employee, m.employee_name AS manager
FROM employees e
LEFT JOIN employees m ON e.manager_id = m.employee_id;

Q3: A primary key, is a column in a relational database table that's distinctive for each record. It's a unique identifier. A relational database must have only one primary key. Every row of data must have a primary key value and none of the rows can be null.

Q4: Some of the SQL operators are: Arithmetic Operators, Bitwise Operators, Comparison Operators, Compound Operators, Logical Operators.

Q5: Very basically, the GROUPING function in SQL helps in dealing with complex queries.

Q6: a relationship refers to the association between tables in a database. And they are: One-to-Many, Many-to-Many, One-to-One
Examples of each:
One-to-Many: Customer that has many Order
One-to-One: Every person has only one ID, or passport
Many-to-Many: Many Products that have Many Customers

@Ammar-coder87
Copy link

**### 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.

  1. Inner Join:

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.

  1. Left Outer Join:

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).

  1. Full Outer Join:

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.

@MahmoudRumaneh
Copy link

Room 2 - Members: Rama Alzeer, Mahmoud Rumaneh, Farah Alsoqi, Lin Daaboul, Sara Jouma

Q1.

SQL serves as a query programming language designed for managing Relational Database Management Systems (RDBMS). MySQL, in turn, is an RDBMS that employs SQL for its operations. The primary function of SQL revolves around querying and manipulating database systems. MySQL, leveraging SQL, facilitates the handling, storage, modification, and deletion of data, ensuring organized data storage.

Q2.

A Database Management System (DBMS) is essentially a computerized system for maintaining and organizing data. Users of the system are provided with tools to perform various operations, allowing for the manipulation of data within the database or the management of the database structure. DBMSs are classified based on their data structures or types.

Types:

A. Object-Oriented Database:

  • Represents information as objects, combining relational database concepts with object-oriented principles.
  • Incorporates concepts like data encapsulation, inheritance, and polymorphism.
  • Requires less code and is easy to maintain.

B. Hierarchical Database:

  • Data elements have a one-to-many relationship (1: N) organized in a tree structure.
  • Hierarchy starts from the root node, connecting child nodes to the parent node.
  • Typically used on mainframe platforms.

C. Network Database:

  • Maintains one-to-one (1: 1) or many-to-many (N: N) relationships among data elements.
  • Organizes data in a graph-like structure, allowing multiple parents for one child record.

Q3.

A primary key in SQL refers to either a single field or a group of fields or columns within a table that serves the crucial function of uniquely identifying each row. In essence, it is a designated column that exclusively accepts distinct values for every individual row.

Q4.

A. Arithmetic SQL Operators:

  • Perform arithmetic operations like addition, subtraction, multiplication, division, and modulus.
  • Examples include + for addition, - for subtraction, * for multiplication, / for division, and % for modulus.

B. Comparison SQL Operators:

  • Check the equality of two expressions.
  • Used in the WHERE clause, comparison operators evaluate if one expression is identical to another.
  • Examples include = for equal to, > for greater than, < for less than, >= for greater than or equal to, <= for less than or equal to, <> or != for not equal to, !> for not greater than, and !< for not less than.

C. Logical SQL Operators:

  • Take two expressions as operands and return TRUE or FALSE as output.
  • Useful in complex SQL statements, these operators function similarly to logic gates.
  • Examples include ALL, AND, ANY, SOME, LIKE, IN, BETWEEN, NOT, EXISTS, OR, and NULL.

Q5.

Group functions in SQL, particularly the GROUPING function, play a crucial role in managing complex queries involving grouping sets, rollup, and cube operations. This function helps differentiate between NULLs representing the absence of data and those present in super-aggregate results. By returning 1 for super-aggregate rows and 0 for regular grouped rows, the GROUPING function aids in clarifying results. Whether used in the SELECT statement, HAVING clause, or ORDER BY clause, this function requires a column name as an argument and must be paired with a GROUP BY clause. Its significance lies in distinguishing NULLs within super-aggregate rows, contributing to clearer and more comprehensible query outcomes.

Q6.

A relationship refers to the established connections between two or more tables, typically based on shared fields. These connections often involve primary and foreign keys.

There are three fundamental types of relationships:

  • One-to-one: Each record in the primary table corresponds to one and only one record in the foreign table.
  • One-to-many: Each record in the primary table has one or more associated records in the foreign table.
  • Many-to-many: Each record in the primary table is linked to multiple records in the foreign table, and vice versa.

@Abdullah-Alawad
Copy link

**Room 8

Abdullah Alawad / Hassan AbuGhareeb / hammam AbuShehadeh / Noor Alrai**

  1. SQL: Structured Query  is a query programming language that manages RDBMS.
    MySQL is a relational database management system that uses SQL.
    
  2. DBMS : Data Base management Systems : system that is used to store and mange data
    Types: -Relational -Network DBMS -Object Oriented DB 
    
  3. (INNER) JOIN : Returns records that have matching values in both tables.
    returns a result that includes rows from both left and right tables.

    LEFT (OUTER) JOIN: Returns all records from the left table, and the matched records from the right table.
    You can imagine it with a Venn diagram with two circles, with the resulting table being the green highlighted part which includes
    both the common/overlapping part, and the rest of the left circle.

    RIGHT (OUTER) JOIN: Returns all records from the right table, and the matched records from the left table.
    The RIGHT OUTER JOIN selects data from the right table (Table B) and matches this data with the rows from the left table
    (Table A). The RIGHT JOIN returns a result set that includes all rows in the right table

    Self Join: join a table to itself, can be viewed as a join of two copies of the same table.

    Cross Join (also known as a cartesian join): returns all combinations of rows from each table.
    CROSS JOIN joins every row from the first table with every row from the second table and its result comprises all combinations of records
    in two tables.

  4. PK: is a field that uniquely identify each record in a table

  5. Arithmetic / Comparison / Bitwise / Logical / Compound

  6.    COUNT(): Counts the number of rows in a set.
       SUM(): Calculates the sum of numeric values in a set.
       AVG(): Computes the average of numeric values in a set.
       MIN(): Finds the minimum value in a set.
       MAX(): Finds the maximum value in a set.  
       
       The need is to summarize Data in one value
    
  7.    Relations the established associations between two or more tables
          One to One:
          One to Many
          Many to Many
    

@gorgees04
Copy link

Gorgees, Dana

What is the difference between SQL and MySQL?

  • SQL is a query language, whereas MySQL is a relational database that uses SQL to query a database.
  • SQL is commercial, MySQL is open source.

What do you mean by DBMS? What are its different types?

  • DBMS is system software for creating and managing databases. A DBMS makes it possible for end users to create, protect, read, update and delete data in a database.
    types
  • Relational DBMS (RDBMS): Uses a table-based format. Data is structured in rows and columns, forming relations. Examples: MySQL, PostgreSQL, Oracle, Microsoft SQL Server.
  • Hierarchical DBMS: Organizes data in a tree-like structure. Data is stored hierarchically with a parent-child relationship.
  • Network DBMS: Similar to hierarchical DBMS but allows each record to have multiple parent and child records.
  • Object-Oriented DBMS: Stores data in the form of objects, as in object-oriented programming.
  • Document-Oriented DBMS: Designed for storing, retrieving, and managing document-oriented information.
  • NoSQL DBMS: Designed for handling big data and real-time web applications. Non-relational and typically distributed.

What are the types of joins in SQL? Give an example for each one:

  • INNER JOIN: SELECT * FROM table1 INNER JOIN table2 ON table1.matching_column = table2.matching_column;
  • LEFT JOIN: SELECT * FROM table1 LEFT JOIN table2 ON table1.matching_column = table2.matching_column;
  • RIGHT JOIN: SELECT * FROM table1 RIGHT JOIN table2 ON table1.matching_column = table2.matching_column;
  • FULL JOIN: SELECT * FROM table1 FULL JOIN table2 ON table1.matching_column = table2.matching_column;

What is a Primary key?

  • The PRIMARY KEY constraint uniquely identifies each record in a table.
  • We can connect tables by PRIMARY KEY to make foreign keys.

What are the different operators available in SQL?

  • Arithmetic Operators (+, -, *, /, %)
  • Bitwise Operators (&, |, ^)
  • Comparison Operators (=, <, >,..etc)
  • Compound Operators (+=, -=, *=, ...etc)
  • Logical Operators (ALL, AND, ANY, ...etc)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment