It is simply a collection of structured data that is organized and stored in a way that allows easy access, management, and updating.
3
New cards
Database Management System (DBMS)
It is software that helps you interact with the database to perform operations such as creating, reading, updating, and deleting data.
4
New cards
Relational Database
A relational database is a type of database that organizes data into rows and columns, which collectively form a table where the data points are related to each other.
5
New cards
Table
It is a collection of related data entries and it consists of columns and rows.
6
New cards
Record or Row
It is an individual entry that exists in a table.
7
New cards
Column
It represents a set of data values of a particular type, one for each row of the table.
8
New cards
Field
It is the intersection of a row and a column in a table. It contains the actual value for a specific attribute of a record.
9
New cards
Attribute (in ERD)
In an Entity-Relationship Diagram (ERD), an attribute is a characteristic or property that defines an entity in the model.
10
New cards
Attribute (in Database)
Within the context of a database, the term attribute can mean any property that a database object can possess.
11
New cards
Name (Attribute)
Every column must have a unique name within its table.
12
New cards
Data Type (Attribute)
This defines the kind of data the column can store, such as integers, strings, dates, etc.
13
New cards
Length or Size (Attribute)
For some data types, such as strings, you can specify the maximum length.
14
New cards
Default Value (Attribute)
You can specify a default value the database system uses if no value is explicitly provided when a row is inserted.
15
New cards
Constraints
Constraints are rules that the database system enforces.
16
New cards
NOT NULL (Constraint)
This means the column must always have a value (it can't be NULL).
17
New cards
UNIQUE (Constraint)
This means all values in the column must be unique.
18
New cards
PRIMARY KEY (Constraint)
This means the column is the primary key for the table. Its values uniquely identify each row in the table.
19
New cards
FOREIGN KEY (Constraint)
This indicates that the column is linked to the primary key of another table.
20
New cards
CHECK (Constraint)
This allows you to specify a condition that the values in the column must meet.
21
New cards
Collation
This is a set of rules determining how string data is sorted and compared.
22
New cards
Auto-Increment
This attribute automatically generates a unique number for each row, typically used with a primary key column.
23
New cards
Expressions
Combinations of symbols, operators, values, and functions used to perform calculations, manipulate data, or evaluate conditions.
24
New cards
Null Value
Represents the absence of any value, indicating that the data is unknown or missing.
25
New cards
Blank (Empty) Value
Refers to an empty character or a whitespace character, stored and retrieved like any other character in a text field.
26
New cards
When Does a Column Value Become NULL?
A column value becomes NULL when no value is provided, explicitly set to NULL, or if the column allows NULL.
27
New cards
No Value is Provided
When a row is inserted without explicitly assigning a value to a column, it defaults to NULL.
28
New cards
Explicitly Set to NULL
When an INSERT or UPDATE statement explicitly assigns NULL to the column.
29
New cards
Column Allows NULL
If the column is defined with NULL allowed, it can hold NULL values.
30
New cards
When Does a Column Value Become EMPTY?
A column value becomes empty when explicitly assigned an empty string, user input results in an empty string, or no default value is provided.
31
New cards
Explicitly Assigned an Empty String
When an INSERT or UPDATE statement assigns an empty string.
32
New cards
User Input Results in an Empty String
If the application layer allows saving empty strings as valid input.
33
New cards
No Default Value for a Column
If a column is set to accept empty strings as valid data and no other value is provided.
34
New cards
Structured Query Language (SQL)
A standardized language used to manage and manipulate data within relational databases.
35
New cards
Projection
A certain column from a table is selected to control which columns to display, without filtering rows.
36
New cards
Selection
A subset of rows or records in a table is retrieved once it satisfies a selection condition.
37
New cards
Joining
Data are combined from two or more tables based on one or more common column values.
38
New cards
DDL (Data Definition Language)
Collection of commands required to define the database, e.g., CREATE, ALTER, RENAME, TRUNCATE, DROP.
39
New cards
DQL (Data Query Language)
Retrieves data from tables, e.g., SELECT.
40
New cards
DML (Data Manipulation Language)
Collection of commands required to manipulate the data stored in a database, e.g., UPDATE, INSERT, DELETE.
41
New cards
DCL (Data Control Language)
Collection of commands dealing with user permissions and controls of the database system, e.g., GRANT, REVOKE.
42
New cards
TCL (Transaction Control Language)
Collection of commands required to deal with the transaction of the database, e.g., COMMIT, ROLLBACK, SAVEPOINT.
43
New cards
SELECT statement
The SELECT statement is used to select data from a database.
44
New cards
SELECT statement syntax
SELECT [ALL or * | DISTINCT] column1, column2, ... FROM table_name [WHERE condition] [GROUP BY column1, column2, ...] [HAVING condition] [ORDER BY column1 [ASC | DESC], column2 [ASC | DESC], ...] [LIMIT number [OFFSET number]];
45
New cards
SELECT clause
SELECT represents the command to retrieve information from the table.
46
New cards
FROM clause
FROM represents the command to identify where the information to gather will come from.
47
New cards
WHERE clause
The WHERE clause is used to filter records. It is used to extract only those records that fulfill a specified condition.
48
New cards
GROUP BY clause
The GROUP BY Statement in SQL is used to arrange identical data into groups with the help of some functions.
49
New cards
Aggregate functions
The most commonly used SQL aggregate functions are: MIN() - returns the smallest value within the selected column, MAX() - returns the largest value within the selected column, COUNT() - returns the number of rows in a set, SUM() - returns the total sum of a numerical column, AVG() - returns the average value of a numerical column.
50
New cards
HAVING clause
Allows the filtering of query results based on aggregate functions and groupings.
51
New cards
ORDER BY clause
The ORDER BY statement in SQL is used to sort the fetched data in either ascending or descending according to one or more columns.
52
New cards
LIMIT clause
The LIMIT clause allows you to specify the maximum number of records returned by a query.
53
New cards
Example of SELECT clause
SELECT name, description FROM department_list;
54
New cards
Example of WHERE clause
SELECT * FROM Employees WHERE Position = 'Manager';
55
New cards
Example of GROUP BY clause
SELECT name, SUM(sal) FROM emp GROUP BY name;
56
New cards
Example of HAVING clause
SELECT Department, sum(Salary) as Salary FROM Employee GROUP BY department HAVING Salary >= 70000;
57
New cards
Example of ORDER BY clause
SELECT Roll_no, Name, Address FROM studentinfo ORDER BY 1;
58
New cards
Example of LIMIT clause
SELECT * FROM student LIMIT 3;
59
New cards
Syntax for SELECT with FROM
SELECT column1, column2, ... FROM table_name;
60
New cards
Syntax for GROUP BY
SELECT column1, function_name(column2) FROM table_name GROUP BY column1, column2;
61
New cards
Syntax for HAVING
SELECT column1, function_name(column2) FROM table_name GROUP BY column1, column2 HAVING condition;
62
New cards
Syntax for ORDER BY
SELECT * FROM table_name ORDER BY column_name ASC | DESC;
63
New cards
Syntax for LIMIT in MySQL
SELECT column_name(s) FROM table_name WHERE condition LIMIT number;
64
New cards
Syntax for LIMIT in SQL/MS Access
SELECT TOP number|percent column_name(s) FROM table_name WHERE condition;
65
New cards
Syntax for LIMIT in Oracle 12
SELECT column_name(s) FROM table_name ORDER BY column_name(s) FETCH FIRST number ROWS ONLY;
66
New cards
Aliases
Aliases are the temporary names given to tables or columns for the purpose of a particular SQL query.
67
New cards
Column Aliases
Temporary names for columns in the result set.
68
New cards
Table Aliases
Temporary names for tables used within a query.
69
New cards
Column Alias Syntax
SELECT column_name AS alias_name FROM table_name;
70
New cards
Example of Column Alias
SELECT EmployeeID AS ID FROM Employee; or SELECT EmployeeID AS 'Employee ID' FROM Employee;
71
New cards
column_name
The column name can be defined as the column on which we are going to create an alias name.
72
New cards
alias_name
It can be defined as a temporary name that we are going to assign for the column or table.
73
New cards
AS
It is optional. If you have not specified it, there is no effect on the query execution.
74
New cards
Table Alias Usage
Used when you want to give a table a temporary name for the duration of a query.
75
New cards
Table Alias Example
SELECT c1.CustomerName, c1.Country FROM Customer AS c1, Customer AS c2 WHERE c1.Age = c2.Age AND c1.Country = c2.Country;
76
New cards
SQL AND Operator
Allows you to filter data based on multiple conditions, all of which must be true for the record to be included in the result set.
77
New cards
SQL AND Operator Syntax
SELECT * FROM table_name WHERE condition1 AND condition2 AND ...conditionN;
78
New cards
SQL OR Operator
Displays the records where any one condition is true, i.e. either condition1 or condition2 is True.
79
New cards
SQL OR Operator Syntax
SELECT * FROM table_name WHERE condition1 OR condition2 OR... conditionN;
80
New cards
SQL LIKE Operator
Used with the WHERE clause to search for a specified pattern in a column.
81
New cards
LIKE Operator Case Sensitivity
LIKE operator is case-insensitive by default in most database systems.
82
New cards
LIKE Operator Syntax
SELECT column1, column2, ... FROM table_name WHERE column_name LIKE pattern;
83
New cards
pattern
The pattern to search for, which can include wildcard characters.
84
New cards
BINARY Keyword
Used in MySQL to make the LIKE operator case-sensitive.
85
New cards
Pattern Matching Example
SELECT * FROM products WHERE name LIKE BINARY 'apple%'.
86
New cards
Wildcard %
Represents zero or more characters.
87
New cards
Wildcard _
Represents a single character.
88
New cards
Wildcard []
Represents any single character within brackets.
89
New cards
Wildcard -
Specify a range of characters inside brackets.
90
New cards
Pattern 'a%' Meaning
Match strings that start with 'a'.
91
New cards
Pattern '%a' Meaning
Match strings that end with 'a'.
92
New cards
Pattern 'a__%' Meaning
Match strings that start with 'a' and contain at least 2 more characters.
93
New cards
Pattern '%wow%' Meaning
Match strings that contain the substring 'wow' in them at any position.
94
New cards
Pattern '_wow%' Meaning
Match strings that contain the substring 'wow' in them at the second position.
95
New cards
Pattern '_a%' Meaning
Match strings that contain 'a' at the second position.
96
New cards
SupplierID, Name, and Address
Retrieve SupplierID, Name, and Address from the suppliers table where the supplier name starts with 'Ca'.
97
New cards
Retrieve entire table
Retrieve entire table, where address contains OKHLA.
98
New cards
IN Operator
The IN Operator in SQL is used to specify multiple values/sub-queries in the WHERE clause.
99
New cards
Syntax of IN Operator
SELECT column_name FROM table_name WHERE condition IN (condition_value1, condition_value2 .....);
100
New cards
Example of IN Operator
SELECT * FROM employee WHERE Name IN ('Ram','Suresh');