Created
July 7, 2021 22:45
-
-
Save m-alikhizar/8bda733df4e610e9398dc1268c82e592 to your computer and use it in GitHub Desktop.
Databases concepts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Two words are used to combine info from two or more tables: | |
// --- UNION --- // | |
Rows are retrieved from one or more tables and stored together, | |
one after the other, in a single result. For example, if your query selected | |
6 rows from one table and 5 rows from another table, the result would | |
contain 11 rows | |
- All the SELECT queries must select the same number of columns. | |
- The columns selected in the queries must contain the same type of data. | |
SELECT lastname, firstname FROM OldMembers UNION ALL SELECT lastname, firstname, FROM Members | |
Depending on how you organized your data, you might have duplicate names. | |
For instance, perhaps a member resigned, and his name is in the OldMember | |
table ó but he joined again, so his name is added to the Member table. If you | |
donít want duplicates, donít include the word ALL. If ALL is not included, | |
duplicate lines arenít added to the result. | |
(SELECT lastName FROM Member UNION ALL SELECT lastName FROM OldMember) ORDER BY lastName | |
// --- JOIN --- // | |
Combining tables side by side is a join. Tables are combined by matching | |
data in a column ó the column that they have in common. The combined | |
results table produced by a join contains all the columns from both tables. | |
For instance, if table1 has two columns (memberID and height), and | |
table2 has two columns (memberID and weight), a join results in a table | |
with four columns: memberID (from table1), height, memberID (from | |
table2), and weight. | |
INNER JOIN: The results table produced by an inner join contains only rows that existed in both tables. | |
OUTER JOIN: The combined table produced by an outer join contains all rows that existed in one table with blanks in the columns for the rows that did not exist in the second table. | |
Mongo DB | |
NoSQL Databases (MongoDB) | |
In NoSQL, main focus is to de-normalize structure. | |
Terminology | |
RDBMS NoSQL | |
Table Collection | |
Row(s) JSON Document | |
Index Index | |
Join Embedding & Linking |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment