Starting from SQL Flashcards
(90 cards)
What is SQL?
It is a programming language with which we can create, maintain and request information from Databases.
What is a Database?
It is an organized collection of data or information.
what are relational databases?
A structured database containing tables that are related to each other.
Tables might be similar in one or more columns.
The columns that relate 2 tables to each other are called keys.
There are other kinds of databases as well.
What are 2 types of keys in relational databases?
Primary key - A column where every row has a unique key.
Foreign key - A column in a table that is a primary key in another tale.
Foreign keys unlike primary keys can have empty values or duplicates.
What is a Query?
A query is a request for data from a database table or a combination of tables.
How we can access SQLite version of SQL from Linux command line?
sqlite3
Give me an example of a scenario where we might Linux as compared to SQL.
Sometimes data format that we need to examine might not be compatible with SQL (for example - text files). For such cases, we need to use Linux.
What are the 2 basic keywords used in SQL queries?
SELECT - indicates which columns to return (* denotes to return all the columns of a table)
FROM - Indicates which tables to query
What keyword do we use to get an ordered result of a query to a database?
We can craft our query to order the query output based on any of the columns in the database.
SYNTAX - >
SELECT customer_ID, city
FROM customers
ORDER BY city;
In descending ->
ORDER BY city DESC;
Note - We can also sort based on multiple columns.
What are the basic filters in SQL queries?
WHERE -> acts as a clause that we use to create a filter
% -> Wildcard
- -> Wildcard
Like -> operator
Give me example of usage of WHERE in SQL.
WHERE country = ‘USA’
WHERE country LIKE “US_”
(In the above statement, underscore will substitute for only one another character )
WHERE name LIKE “man%”
(Above, percentage sign will substitute for any number of other characters)
WHERE NOT country = “USA”
What are the common datatypes in Databases?
Strings, Numbers, Data and Time
Note - Data and Time need to be enclosed within quotation marks like strings.
Give me an example of filtering use of comparison operator in SQL.
SELECT *
FROM employees
WHERE birthdate > ‘1970-01-01’;
What is inner join in SQL database tables?
It returns rows matching a specified column that exists in more than one table.
When we use INNER JOIN, all the columns in both tables are returned.
If the column exists in both of the tables, it is returned twice when SELECT * is used
What are different kinds of Joins in SQL?
Inner Join
Left Join
Right Join
Full join
Give me an example of Inner join syntax.
SELECT username, operating_system, employees.device_id
FROM employees
INNER JOIN machines ON employees.device_id = machines.device_id;
What are aggregate functions in SQL?
Count - returns a single number that represents the number of rows returned from your query.
AVG - for average
SUM - for sum
SELECT COUNT(firstname)
FROM customers
WHERE Country = ‘USA’;
How do we calculate risk to some asset?
Its formula is
Likelihood * impact = Risk
It depends on how often a risk can be exploited and what its impact on the organization if it is exploited.
What are the categories of a threat?
Intentional threat -
Unintentional threat -
Outsider threat -
Insider threat -
What are the 2 categories of vulnerabilities?
Technical vulnerability
Human vulnerability
What is Asset management?
It is the process of making an inventory of all the organization’s assets, tracking all the assets, and finding out all the associated risks to these assets.
It also includes asset classification.
What is asset classification?
Asset classification is the process of classifying assets based on how important an asset is to an organization and how sensitive it is.
How do we find out the sensitivity and importance of an asset to an organization?
To know the sensitivity and importance of an asset to an organization, we normally ask the following questions:
- What you have
- Where it is
- Who owns it
- How important it is
What are the common asset classifications that an asset can be categorized into?
- Restricted
- Confidential
- Internal only
- Public