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.

@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