Server Side Development Final

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/162

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

163 Terms

1
New cards

URI

URI is an abbreviation for Uniform Resource Identifier. It is a string of characters that identifies a web resource by name, location, or both. A URI can be broken down to a URL or a URN.

2
New cards

URL

Uniform Resource Locator. This specifies the particular method of retrieving a given resource on the Internet. HTTPS, FTPS, etc.

3
New cards

URN

URN means Uniform Resource Name. This is a persistent and location-independent way of identifying a resource. The name stays the same even if the resource moves to another location.

4
New cards

Static Website

The web server relays the requests from the client to other parts of the server, where resources are located. The web server packages the response back to the client. The client then visualizes the response in their browser.

5
New cards

Dynamic Website

All that you can do with a simple static website is retrieve its content. However, with a dynamic website the website content is created dynamically, by inserting bits of data into the webpage into placeholders. This is classically called server-side programming nowadays. The server also includes databases, or other storage locations for storing resources. It also has a web application, which assembles data and resources necessary for the client’s web browser. The web application retrieves files and data from the Database to dynamically render the web page.

6
New cards

GET Request

GET is used when you want to retrieve information from the server. Often uses a list of parameter names and values to retrieve information. The response from a GET request can often be stored in the cache.

7
New cards

POST Request

Used when a user posts information to the server. Sending a POST request multiple times creates the very same resource multiple times! Beware

8
New cards

PUT Request

In contrast with POST, The PUT request is used to update an existing resource on the server. If the resource does not yet exist, then PUT will create the resource (in this way it will act like POST). Example: updating posts on social media. Note: sending a PUT request multiple times produces the same result each time (it is idempotent).

9
New cards

DELETE Request

This is used to delete a resource on the server. The structure is similar to GET, no data is posted in the body of the DELETE request.

10
New cards

XML

XML stands for eXtensible Markup Language

11
New cards

JSON

JSON stands for JavaScript Object Notation. JSON can use arrays, whereas XML can’t.

12
New cards

XML Format

<play>

<title>Hamlet</title>

<author>William Shakespeare</author>

<length>45</length>

</play>

13
New cards

JSON Format

{

“title”:”Hamlet”,

“author”:”William Shakespeare”,

“length”:45

}

14
New cards

XML List

<server>

<users>

<user>tommy</user>

<user>sammy</user>

<user>timmy</user>

</users>

</server>

15
New cards

JSON Array

{

name”: ”Concordia University Irvine”,

“num_students”: 4900,

“departments”: [

“Engineering”,

“Math”,

“Computer science”

],

“president”: “Michael Thomas”

}

16
New cards

What is a cron job?

  • We can set up automated jobs on the server (usually a Linux server).

  • These jobs are executed at regular time intervals.

  • In Windows, these scripts correspond to background services.

17
New cards

Examples of cron jobs

  • Populating a database based on data scraped from the Internet at a regular interval.

  • Backing up files

  • System maintenance

  • Disk space monitoring, i.e. garbage collection

18
New cards

Limitations of cron jobs

  • A particular job can only be repeated after one minute, no less.

  • 59 seconds is not possible.

  • Can only be run on one computer, cannot be distributed.

  • The job cannot be run if it crashes.

19
New cards

How to Write a Cron Job

  • A typical cron job descriptor has 6 fields:

  1. Minute: the minute of the hour the job should run: 0-59

  2. Hour: the hour the job should run (24 hour system): 0-23

  3. Day: the day of the month the job should run: 1-31

  4. Month: the months that the job should run: 1-12

  5. Day of the week: 0-6, where 0 represents Sunday

  6. The command/script/program itself

  • No fields should be left blank.

20
New cards

Cron Job Asterisk (*)

  • this signifies all possible values for a given field.

    • In the hour field it goes from 12 am to 11 pm, 00 to 23.

21
New cards

Cron Job Comma (,)

  • with this you can list multiple values in a field.

    • i.e. 2,4,5 means every Tuesday, Thursday, and Friday in the “day of the week” field

22
New cards

Cron Job Hyphen (-)

  • determines a range of values

    • 11-20 in the Day field means from the 11th to the 20th of every month

23
New cards

CJ Separator (/)

  • This divides a value.

    • i.e. */6 in the day field means every six days.

24
New cards

CJ Last (L)

  • can be used in the day of week and day of month fields

    • i.e. 4L in the day of week field means the last Thursday of the month

25
New cards

CJ Weekday (W)

  • This denotes the first weekday from a given time point.

    • i.e. 15W means the weekday closest to the 15th of the month.

    • If the 15th is a Sunday, then the cron job will run on the 16th of the month.

26
New cards

CJ Hash (#)

  • this determines the day of the week

    • i.e. 5#3 means the third Friday of the month, 2#2 means the second Tuesday of the month.

27
New cards

What is n-tier architecture?

  • An n-tier application is a program that is distributed among multiple separated computers in a distributed network.

28
New cards

N-Teir 3 Layers

  • The interface layer on the user’s computer (presentation layer)

  • A server computer that manages a database (database layer)

  • A centralized middle-layer computer that handles the business logic between the user and the server (application/business layer)

29
New cards

Tier vs Layer

  • A layer is a logical component of the architecture that accomplishes a given function.

    • i.e. calculating a result, such as someone’s BMI

    • Registering a new applicant

    • Retrieving data from a database

    • Visualizing results

  • A tier the hardware platform on which the logical layer runs.

30
New cards

The 3-Layer Model

  • A 3-tier system has all three basic layers: 

    • Presentation layer

    • Business/application/logic layers

    • Server/database layer

31
New cards

Presentation layer

  • The ‘frontend’, the user interface (UI).

  • Translates tasks so they are understandable and viewable by the user.

    • HTML, CSS, JavaScript, webforms

  • Sends requests to the other two layers.

  • Presents data retrieved from the server/database layer to the user.

  • Requires the least security.

32
New cards

Application/Business/Logic layer

  • The heart of the application, here is where the “business logic” is applied.

  • Business logic means how the application should be run to achieve its goals.

  • Accepts the client’s data and passes it on to the database layer much like an interface.

  • Coordinates processes.

  • Makes logical evaluations and decisions and performs calculations.

33
New cards

Database layer (the backend)

  • Contains the Database Management System

    • i.e. Cassandra, CouchDB, MongoDB

  • Stores data in databases.

  • Receives data from the business layer.

  • Performs the actual requested operations on the database.

    • i.e. SELECT statements

  • Sends back requested data via the business layer.

34
New cards

Advantages of n-tier architectures

  • Security: each of the three layers can be secured independently from one another.

    • A hacker has to hack all three layers independently to be successful.

  • Management: each of the three layers can also be managed independently.

  • Each component in the multi-tier architecture is:

    • Scalable: new resources can be added easily.

    • Reusable: each tier can easily be reused for other projects.

  • Each component in the multi-tier architecture is:

    • Flexible: each layer can be expanded any way you desire.

      • Different business logic in different countries.

      • Presentation layer in different languages.

      • Or in different layout on a PC, smart phone, or tablet.

  • Each tier can be developed quickly by itself.

  • N-tier architectures can be moved into the cloud which makes development cheaper.

35
New cards

Disadvantages of n-tier architectures

  • Due to the presence of multiple layers in the n-tier architecture, more effort is needed to establish it due to higher complexity.

  • More complexity also means more opportunities for system failure.

  • Performance may decrease due to constrictions in I/O flow.

36
New cards

Form validation

  • The data entered in HTML forms need to be validated:

  • HTML, PHP and Javascript make it possible to ensure that the right values are transmitted from the form.

    • Check for missing values

    • Check that values are within bounds (nobody has a negative height)

    • Checks if the input is the right pattern

    • Guard against SQL injections!

37
New cards

HTML form validation

  • In this case, the form is validated by certain elements in the HTML code itself.

  • If the conditions set in these fields are violated, the form is not submitted.

  • Each input field can have attributes for:

  • type, required, min, max, pattern, disabled, size, readonly, maxlength, etc…

38
New cards

required:

the input must be filled in and does not advance if empty

39
New cards

min and max

min: minimum value required. max: maximum value required.

40
New cards

pattern:

the input must conform to a specified pattern. It follows regex patterns (see Linux programming).

41
New cards

disabled:

user cannot enter data.

42
New cards

readonly:

user cannot enter data, thus the same value is submitted in all cases.

43
New cards

maxlength:

allows input up to a certain length. Good against hacking attacks.

44
New cards

HTML versus Javascript validation

  • HTML validation happens first, then Javascript validation. HTML also overrides JS validation if both reference the same HTML element.

  • Javascript form validation allows finer control than HTML.

  • For example, HTML allows any kind of eye or hair color, whereas Javascript can restrict it to certain values.

45
New cards

Validation with Javascript

  • Javascript can also be used to validate forms.

  • As mentioned earlier this can happen in the <head> portion of the HTML or between <script> tags.

  • A validation function handles form validation.

  • It retrieves the value of each element in this way:

  • document.forms["studentForm"]["name"].value:

    • documents: this represents the entire HTML page.

    • forms: this contains the names of all of the forms on the page.

    • document.forms["studentForm"]["name"] references the ‘name’ variable on the form called ‘studentForm’

    • Value represents the value of the name, i.e. John Smith.

46
New cards

Document Object Model

  • The Document Object Model (DOM) is a way of accessing HTML elements via Javascript.

  • Under development since the mid-1990s, we ae currently at DOM5.

  • Each HTML element in a page belongs to a hierarchy: forms, tables, input fields, etc.

  • Following this line of hierarchy, we can access every single HTML element.

47
New cards

Accessing HTML elements via DOM

  • There are three ways of accessing an HTML element via the DOM:

  1. The DOM address

  2. By its name

  3. By its id

48
New cards

Access via DOM address

  • The root element of an HTML page is ‘document’.

  • Associated with each document is a set of forms, tables, frames, etc…

  • Therefore, to access the first form on the HTML page, you reference it by: document.forms[0]

  • The form’s elements may be accessed by: document.forms[0].elements[0]

49
New cards

Access via element name

  • This way we access the document’s elements by naming them.

  • Thus, the element 

    • document.forms["patientForm"]["telephone"].value

  • Can be rewritten this way:

    • document.forms.patientForm.telephone.value

50
New cards

Direct access via id

  • Probably the simplest way of accessing HTML elements, you simply need to use the document.getElementById(<element id>) function.

  • This accesses the form element by id.

  • Thus, the element (by name)

    • document.forms["patientForm"]["telephone"].value

  • Can be rewritten this way:

    • document.getElementById(“telephone”)

51
New cards

REGEX Pattern

  • The pattern is always placed in between the two / symbols called anchors. The pattern must fit inside the two anchors.

  • Anchors represent regular expressions in awk, perl, and other languages.

  • The anchors are not symbols themselves, they only contain the pattern.

  • ^ means that the text must begin with the specified pattern.

  • $ means that the text must end with the specified pattern.

52
New cards

\d

A digit

53
New cards

\D

Not a digit

54
New cards

\w

A word (alphanumeric character)

55
New cards

\W

Not a word character

56
New cards

\s

A whitespace character: space, return (\r), tab (\t), line feed (\n), form feed (\f)

57
New cards

\S

Not a whitespace

58
New cards

.

Any character. Note: \. Means a period.

59
New cards

[^]

Anything but what ever comes after the up arrow

60
New cards

{3}

means a digit occurs exactly 3 times, i.e.: “God’s number is 777”

61
New cards

{3,4}

means that a digit occurs 3 or 4 times, i.e. “-3882-” and “-601-”

62
New cards

{3,}

means it occurs at least 3 times, i.e. “92888181”, but “a34b” does not.

63
New cards

?

Means that the character occurs either once or never.

64
New cards

+

means that the character must occur at least once, i.e. /a+/ matches ‘cat’ and also ‘Transvaal’, but not ‘joke’

65
New cards

*

means that the character can occur any number of times, i.e. .txt matches all text files.

66
New cards

Non-relational databases

  • The first computer-based databases contained data in a non-relational format.

    • Relational: data in separate data tables are associated with one another in some way

  • The two main non-relational database types are:

    • Hierarchical databases

    • Network databases

67
New cards

Hierarchical databases

  • Each node may also have 0, 1, or more child nodes.

  • You go from the root node to leaf nodes by traversing many intermediate nodes.

  • Fast usage

  • Inflexible: to get to data at the bottom of the hierarchy you always have to go through all the parent nodes above it.

68
New cards

Network databases

  • Consists of:

    • Sets of records

    • Sets of links that define relationships between different records

  • Records contain fields (as in a data table)

    • Pointers are used to direct the user from one table to the next

  • Since many different relationships exist between different records, there is no need to go through all levels of a hierarchical database.

69
New cards

What is a relation?

Essentially a table. An entity is something of importance represented in the database as a row.

70
New cards

the seven most important characteristics of relations:

  1. Rows contain related pieces of data about a specific, unique entity.

  2. Columns contain data about the entity’s attributes.

  3. All entries in a column must have the same type.

  4. Each column has a unique name, and each row has a unique identity.

  5. No two rows can be identical.

  6. Cells in the table each hold a single value only, no comma-separated values.

  7. Row and column order is unimportant (although it can be helpful).

71
New cards

relation structures

Relation_name(column_1, column_2, … column_n). Foreign keys are in italics. Primary Keys are underlined.

72
New cards

Database integrity constraints

  • Domain integrity

  • Entity integrity

  • Referential integrity

73
New cards

Domain integrity constraint

  • A domain is a data grouping that meets a specific definition.

  • All values in a given column must have the same type.

  • For example, every value in a hypothetical column first_name must be a string: Arnold, Betty, Cathy, Dylan, etc., not a number, like 86

74
New cards

Entity integrity constraint

  • When selecting a primary key, whether it has a single or multiple columns, it must have unique data in it.

  • Longer keys are more likely to be unique but need more overhead.

  • Shorter keys are more practical but may not be unique.

75
New cards

Referential integrity constraint:

  • When defining a foreign key that references another table, each foreign key must match up with a value in the other table.

  • Otherwise, you get an error.

  • This is important later on for performing data queries.

76
New cards

Key types(7)

  • Single column

  • Composite

  • Candidate

  • Primary

  • Alternate

  • Surrogate

  • Foreign

77
New cards

What is a key?

  • A key is one or more columns of a table that can be used to identify a set of rows.

  • A key can be unique or non-unique.

  • If the key is unique, it identifies only one single row.

  • Conversely, non-unique keys may identify one or multiple rows!!

  • We want unique keys!

78
New cards

Single Column Key

A single column key corresponds to a single column in the table that we want to use to uniquely identify rows.

79
New cards

composite key

covers two or more columns in order to be unique.

80
New cards

Primary Key

A good key that uniquely identifies each row. Unique to each table.

81
New cards

candidate keys

Several single-column/composite keys that could act as primary key

82
New cards

alternate keys

the “losing” candidate keys that were not chosen to be the primary key

83
New cards

Surrogate keys

  • The database structure may change, and as such, it is good to have surrogate keys if they need to become primary keys.

  • (Remember, surrogate keys were candidate keys that were not chosen – they act like vice presidents when the president is incapacitated)

  • Many times a simple solution is to assign a row number to each row, which will be a surrogate primary key. Simple and guaranteed to be unique.

  • Some DB systems automatically generate such a row number acting as a surrogate primary key using auto_increment.

84
New cards

Foreign key

  • Records in separate tables are connected by redundant values in a special column called the foreign key.

    • If you want to get more information in another table, you can navigate there via the foreign key which has the same value in both tables.

    • This is the relational aspect of relational databases.

85
New cards

What is a functional dependency?

  • If a box of cookies is $5, and we have 7 boxes, the total price is 7 x $5 = $35.

  • Here the NumberOfBoxes determines the TotalPrice.

  • X and NumberOfBoxes are so-called determinants.

  • NumberOfBoxes => TotalPrice is called a functional dependency.

86
New cards

Unsigned vs. Signed Ints

Signed - Positive or Negative

Unsigned - Only Positive

87
New cards

TinyINT

255, 1 Byte of Storage

88
New cards

SmallINT

65535, 2 bytes

89
New cards

Medium INT

16 million, 3 bytes

90
New cards

INT

4 billion, 4 bytes

91
New cards

BIGINT

more than 4 billion ig

92
New cards

Fixed point, decimal types

  • Decimal types have two parts:

    • The precision, or the number of digits for the entire number (integer and fraction parts together).

    • The scale, or the number of digits in the fractional part.

    • For example: expression_level DECIMAL(7,3) may contain numbers from -9999.999 to 9999.999

93
New cards

BIT

  • BIT(M), where M can range from 1 to 64 bits

  • BIT(5) can take values from 00000 (0) to 11111 (31)

    • 2^5 = 32 possible values

94
New cards

CHAR(#)

Stores a string that HAS to be length of the number and will be padded to the length if not.

95
New cards

VARCHAR(#)

Stores a string with variable length that has a max length = to the #.

96
New cards

TEXT

  • Use these data types if you need something larger than char or varchar.

  • TEXT: this data type can contain a string of up to 65,536 characters, in 16 bytes (2 = 65536)

  • TINYTEXT: 2 = 255 characters

  • MEDIUMTEXT: 2 = 16,777,215 characters

  • LONGTEXT: 2 = 4,294,967,295 characters

97
New cards

ENUM

  • ENUM (enumeration): A string object can have as many as 65,536 distinct values, including NULL and ‘’ listed in the ENUM.

  • i.e. temperature ENUM(‘freezing’, ’cold’, ’mild’, ‘warm’, ‘hot’)

  • These must be referenced by their index number (1=freezing, 2=cold, etc.)

  • only one value can be selected

98
New cards

SET

  • SET: a set of zero or more unique values that you can choose from.

    • The empty set can be defined as a data type, but not useful practically speaking.

  • i.e. color SET(‘red’, ‘green’, ‘yellow’, ‘blue’, ‘orange’)

  • allows multiple values to be selected

99
New cards

What does CRUD stand for?

  • Create a data table

  • Read (query) a data table to extract information

  • Update, or change the data found in the data table

  • Delete data from a database

100
New cards

1:1 Relationship

  • If a row in a given table can reference only one row in another table, this is an example of a 1:1 relationship.

  • For example, if we have a table called men and a table called women, then one man may reference only one woman.