(DATABASE MANAGEMENT SYSTEM)
Â
Example Database
Relational vs No-SQL
Relational | No-SQL |
---|
  Deployed in vertical             fashion. |  Deployed in horizontal           fashion |
---|
 ACID(Atomicity, Consistency,Isolation,Durability) properties | Eventually consistent |
---|
Fixed schema | Flexible schema |
---|
   Read scalability only | Read and write scalability |
---|
  centralized structure | Decentralized structure |
---|
More insights about DBMS
Keys
Candidate key
Super key
Foreign key
Primary key
Relationships
One to Many
Many to Many
One to One
Many to One
E-R Diagrams
Main Components of ER diagram
Entities-Â Represented by
Attributes-Represented byÂ
Relationships-Represented byÂ
Example of making ER diagram
In a university, a Student enrolls in Courses. A student must be assigned to at least one or more Courses. Each course is taught by a single Professor. To maintain instruction quality, a Professor can deliver only one course
Step 1(Identification of Entities)
Relationship Identification
Step 3(Cardinality Identification)
In a university, a Student enrolls in Courses. A student must be assigned to at least one or more Courses. Each course is taught by a single Professor. To maintain instruction quality, a Professor can deliver only one course
Step 4(Identification of Attributes)
Step 5 ( Finalising the diagram)
Weak Entity Set
Entities dependent on strong entities
Referential Integrity
Correspondance between two rows of different tables through a foreign key
Example:- Table1: customer(custID,cusName)
            Table 2: Order(OrderID,CustID,OrderDate)
Here every orderID from Table2 must match with a valid custID form Table1
Normal Forms
What is Normalization
Â
Ans: Reducing data Redundancy from a relation or a set of relations
Major 5 types of normal forms
First Normal Form
Second Normal form
Third Normal Form
Boyce and Codd Normal Form
Fourth Normal Form
SQL
(Structured Query Language)
SELECT
SELECT <COLUMN_NAME> from <DATABASE_NAME>
//Select a column from a database
SELECT Customers from [CUSTOMERS]
//Select all columns in a database
SELECT * FROM [CUSTOMERS]
Similar to SELECT is SELECT DISTINCT which allows to choose only distinct values
WHERE
SELECT column1, column2, ...
FROM table_name
WHERE condition;
//EXAMPLE
SELECT * FROM Customers
WHERE Country='Mexico';
INSERT INTO
INSERT INTO table_name (column1, column2, column3, ...)
VALUES (value1, value2, value3, ...);
//EXAMPLE
INSERT INTO Customers (CustomerName, City, Country)
VALUES ('Cardinal', 'Stavanger', 'Norway');
SUM(),COUNT(),AVG()
//COUNT
SELECT COUNT(column_name)
FROM table_name
WHERE condition;
//AVERAGE
SELECT AVG(column_name)
FROM table_name
WHERE condition;
//SUM
SELECT SUM(column_name)
FROM table_name
WHERE condition;
WILDCARDS
USED with LIKE keyword
syntax may differ with application where SQL database is running
On a SQL server
GROUP BY
Groups the data based on provided conditions
//General Syntax
SELECT column_name(s)
FROM table_name
WHERE condition
GROUP BY column_name(s)
ORDER BY column_name(s);
Thank You