M2 Flashcards

1
Q

What is LAMP?

A

Linux
Apache
MySQL
PHP (Perl or Python)

Called a LAMP Stack, there are other versions of stacks such as WAMP ( w=windows) or MERN(mongodb express react node)

LAMP is one of the most originals

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is an IP address?

A

Internet protocol address - rules to determine addresses

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is DNS?

A

Domain name system

Turns a user-friendly domain name like bbc.co.uk into an IP address.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is a URL?

A

Uniform resource locator

A reference that is unique to each resource on the web.
http://www.bbc.co.uk/football

It could be the address of a webpage, or a CSS file, or an image file.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is HTTP?

A

HTTP
Hypertext Transfer Protocol

Allows HTML documents to be requested and transmitted between browsers and web servers via the internet.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is a web server?

A

A computer that stores web server software and a website’s component files (for example, HTML documents, images, CSS stylesheets, and JavaScript files).

Software that includes several parts to control how web users access hosted files. At the very least it understands URLs (web addresses) and HTTP (the protocol browsers use to view webpages).

So the term “web server” can refer to either hardware or software, or both of them working together.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is static content?

A

Any content that can be delivered to an end user without having to be generated, modified, or processed. Such as images, audio, video etc

The server delivers the same file to each user.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is dynamic content?

A

Any content that must be generated, modified, or processed before being delivered to a user. For example, IMDB and different people looking for different films.

One user receives different content than another user.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Describe the HTTP request response cycle?

A

HTTP Response cycle - browser to web server with a HTTP Request then either back to browser if static or onto PHP , PHP willo load the file and builds the webpage to send back to web server that sends it back to the browser in a HTTP Response

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is docker and why do we use it?

A

Docker is a containerized virtual environment that makes it easy to develop, maintain, and deploy apps and services

It replicates the live server as closely as possible for consistency, so we can test our stuff before deploying it to the server.

This creates a standard environment for all developers. Each developer has all the same versions in the LAMP stack as every other developer and the live server.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is an IDE AND why do we use them?

A

Integrated development environment

It knows the development language
can spot syntax errors
can make autocomplete suggestions

It has built-in tools for many tasks such as testing, accessing database, etc.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is a variable?

A

A box to store data

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is a constant?

A

A box that never changes its contents, i.e its value is fixed.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is a data type?

A

A data type is a classification that specifies what type of value a variable can have and what type of operations (mathematical, relational, logical, etc) can be applied to it without causing an error.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What are the 3 data types in PHP?

A

Scalar data types scale is something you can count
i.e string, integer, float, boolean

Compound or complex data types
i.e array, objects

Special data types
i.e null

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Difference between static and dynamic typing?

A

Static vs. Dynamic defines how a language expects you to declare data types. Static typed languages require explicit definition of a data type when they create a piece of data (e.g. variable, parameter, return value). Dynamic languages are the opposite and can infer, or at least try to guess, the type that we’re using.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Difference between strong and weakly typed?

A

Strong vs. Weak defines how flexibly a language allows operations between data types. For example, strongly typed languages will not allow you to add a float to an integer, without you converting it first, even though they are both numbers. On the other hand, a weak language will try its best to accomodate what the programmer is asking and perform these operations

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What is type juggling?

A

When an expression contains variables of different types, PHP will first convert their values to a common, comparable type.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What is the comparison operator?

A
== compares the values i.e 
=== compares the data type as well
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

What is the ternary operator?

A

The ternary operator is used to shorten if/else structures.

The ternary operator is used to shorten if/else structures.

condition ? value if true : value if false;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

What is the null coallescing operator?

A

The null coalescing operator returns its first (i.e. left) operand if it exists and is not null; otherwise, it returns its second (i.e. right) operand.
$val1 = $undefined ?? ‘fallback(1)’;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

What is an array?

A

An array stores multiple values in one single variable:

can be indexed or associative

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

What is a function?

A

A function is a repeatable, i.e. reusable, set of instructions.

Two types:
user-defined functions
built-in functions

A function can have a parameter passed into it. Arguments are the values that are passed into the parameter

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

What is type hinting?

A

We can type hint parameters and return types to ensure inputs and outputs are as expected

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

How do we use optional/default parameters?

A

Optional parameters (i.e. ones with default argument values) should always be at the end of the parameter list.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

List some PHP built in functions

A
ceil
floor
count
is_array
explode - string to array
str_split - each character of string to array
implode - array to string
str_replace
27
Q

What are comments and docblocs?

A

Comments are additional information about your code that is ignored by the parser. ( analyse )

Documentation for structural elements such as functions. Used to provide more detailed information in comments.

28
Q

What is pseudocode?

A

Write the steps down in an English-like language. It’s a made up language, so syntax rules don’t apply and therefore don’t slow you down.

A bulleted or numbered list works.

Focus on describing the solution.

29
Q

What is a database?

A

Permanent data storage. Persistent data - it’s still available after the program has finished.

The data is stored in a structured/organised way, i.e. optimised, for reading and writing the data as quickly as possible.

30
Q

What is a relational database and a RDMS?

A

Traditional type of database.

A collection of tables - like a collection of spreadsheets.

RDBMS - relational database management system - is the program that allows you to create, update, and administer a relational database.

i.e MySQL

31
Q

What is a NoSQL database and a RDMS?

A
32
Q

Other types of database?

A

Object oritented database :
A collection of objects - each object is a combination of data and attributes of the data.

Hierarchical database
Looks like a family tree, with one node on top branching down to multiple nodes beneath it.

Document databases
Also known as document stores.
Use JSON-like documents to model data.

33
Q

What is SQL and basic syntax?

A

Structured query language.

SQL is a language used to access the database . SQL actually consists of several sub-languages.

By convention, the commands and other keywords are written in uppercase.

Each command ends with a semicolon.

In MySQL, the names of columns and tables are enclosed in backticks.

34
Q

SQL Datatypes?

A
INT or INTEGER
SMALLINT
BIGINT
TINYINT
FLOAT
DOUBLE PRECISION
REAL
VARCHAR(255)
DATE
TIME
TIMESTAMP
BLOB - Binary Large Object, Used to store large amounts of data, such as images, video clips and audio clips.
35
Q

What is a Field?

A

An individual item of data. E.g. age, height, miles_per_gallon

A field is also called a column or an attribute.

36
Q

What is a Record?

A

A group of fields about a single person, item or object.

A record is also called a row or tuple.

37
Q

What is a table?

A

A group of records.

38
Q

What is an ID?

A

A unique identifier for each record (row) in the table.

39
Q

What are DDL and DML?

A

DDL - Data Definition Language
Commands to create, alter or delete tables.

DML - Data Manipulation Language
Commands to interact with the data in the database.

40
Q

How to we create a table in SQL?

A

Use a CREATE TABLE statement to specify the layout of your table.

CREATE TABLE `cows` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) DEFAULT NULL,
  `age` int DEFAULT NULL,
  PRIMARY KEY (`id`)
);
41
Q

How do we insert in SQL?

A

INSERT INTO cows (name, age) VALUES (‘Daisy’, 2);

42
Q

How do we update in SQL?

A

UPDATE cows SET age = 2 WHERE id = 1;

43
Q

How do we delete?

A

DELETE FROM cows where id=1;

44
Q

How do we select?( using alias)

A

SELECT name AS ‘Pig Name’, colour
FROM pigs;

Using an alias Can help if the column name is ambiguous. Is the name a pig’s name or an owner’s name?

Can also help if the column name is really long.

45
Q

How do we use where?

A

WHERE filters the data.

SELECT name AS ‘Pig Name’, colour
FROM pigs
WHERE weight > 285;

46
Q

How do we use group by?

A

SELECT COUNT(id), colour
FROM pigs
GROUP BY colour;

The GROUP BY statement is often used with aggregate functions (COUNT(), MAX(), MIN(), SUM(), AVG()) to group the result-set by one or more columns.

47
Q

How do we use order by?

A

SELECT id, name
FROM pigs
ORDER BY name DESC;

ASC is default

48
Q

What order do we write statements?

A
(S)illy - SELECT
(W)itches - WHERE
(G)row - GROUP BY
(O)ld - ORDER BY
(L)umps - LIMIT
49
Q

What is an SQL join?

A

A join allows us to combine data from multiple tables together in a single query, avoiding the need to try and use multiple select statements and then trying to merge them in PHP.

Foreign key - a column that points to the primary id in another table, so we can link data from other tables.

50
Q

What is an Inner Join?

A

The INNER JOIN keyword selects records that have matching values in both tables.

SELECT people.name, locations.name
FROM people
INNER JOIN locations
ON people.location = locations.id;

51
Q

What is a left join?

A

Contains all the data from the left side (the table on the left of the =) along with any matching data from the right side (the table that is being joined).

SELECT people.name, colours.name
FROM people
LEFT JOIN colours
ON people.fav_colour = colours.id;

52
Q

What is a foreign key?

A

A FOREIGN KEY is a field (or collection of fields) in one table, that refers to the PRIMARY KEY in another table.

Data in one table that relates to data in another table.

It usually relates to an id in another table.

CONSTRAINT fk_people_locations FOREIGN KEY (location) REFERENCES locations(id)

53
Q

What is PDO and its benefits?

A

PHP data objects.

PDO is a library and will be present on any industry standard VM.

PDO benefits are:
security - usable prepared statements
usability - many helper functions to automate routine operations
reusability - a unified way to access a multitude of databases, from SQLite to Oracle

Use PDO to create a connection to the database.

54
Q

What is the 3 step process for PDO connections?

A

Three step process:

  1. Connect to database
  2. Prepare statement
  3. Execute query

Wrap in a try catch

55
Q

What is SQL injection?

A

Malicious code inserted into user inputs to compromise the database.

56
Q

How can SQL injection be avoided?

A

Prepared statements protect from SQL injection, and are very important for web application security.

Prepared statements include placeholders for where data will be.

Specifying the data for placeholders is called binding parameters.

$query = $pdo->prepare(
‘INSERT INTO people (name,location,fav_colour)’
. ‘VALUES (:newName, :location, :favColour)’
);

57
Q

What is the Like function?

A

Advanced where

The LIKE operator is used in a WHERE clause to search for a specified pattern in a column.

There are two wildcards often used in conjunction with the LIKE operator:
The percent sign (%) represents zero, one, or multiple characters.
The underscore sign (_) represents one, single character.

58
Q

What is the between function?

A

BETWEEN
Selects an inclusive range.
SELECT name FROM pigs WHERE weight BETWEEN 280.5 AND 300;

59
Q

What are transactions?

A

A set of database operations that get run as a single group.

If one fails, the RDBMS won’t apply any of the operations, and the database is left unchanged. This is called roll back

A database transaction must be atomic ( ACT AS A SINGLE UNIT ), consistent, isolated and durable - ACID.

60
Q

What is ACID?

A

Atomicity - if one query fails, everything is undone and nothing happens
Consistency - database changes in a reliable way
Isolation - transactions cannot affect each other
Durability - results are committed all at once

61
Q

What is a one to many relationship?

A

i.e a blog post, One post has many comments.

62
Q

What is a One-to-One relationship?

A

Country - capital city. Each country has exactly one capital city. Each capital city is the capital of exactly one country.

63
Q

What is a many to many relationship?

A

A post can have many tags. A tag can apply to many posts.

To implement a many-to-many relationship, two one-to-many relationships are used with an intermediate table called a link or junction table.