Test 1 Flashcards

1
Q

Example of a having clause with a WHERE

A

SELECT Employees.LastName, COUNT(Orders.OrderID) AS NumberOfOrders
FROM Orders
WHERE (Orders.EmployeeID = Employees.EmployeeID) AND (LastName = ‘Davolio’ OR LastName = ‘Fuller’)
GROUP BY LastName
HAVING COUNT(Orders.OrderID) > 25;

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

Two ways to execute a query in php

A

When not trying to display anything:
$query = $conn->prepare($sql);
$query->execute();

When you’re trying to display something:
$result = mysqli_query($conn, $sql);
while($row = mysqli_fetch_array($result))

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

Characteristics of a linked or doubly linked list?

A

Head - It is the first memory location that is in the list
Node - The actual piece of information that is stored in that location in the array
Null - When a node doesn’t point forwards or backwards to any other node
Memory Location - It is the location of that node in the array
Previous Pointer - That is the memory location of the previous node in the list
Next Pointer - That is the memory location of the next node in the list

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

Examples of media queries

A
/* For mobile phones: */
[class*="col-"] {
  width: 100%;
}
@media only screen and (min-width: 600px) {
  /* For tablets: */
  .col-s-1 {width: 8.33%;}
  .col-s-2 {width: 16.66%;}
  .col-s-3 {width: 25%;}
  .col-s-4 {width: 33.33%;}
  .col-s-5 {width: 41.66%;}
  .col-s-6 {width: 50%;}
  .col-s-7 {width: 58.33%;}
  .col-s-8 {width: 66.66%;}
  .col-s-9 {width: 75%;}
  .col-s-10 {width: 83.33%;}
  .col-s-11 {width: 91.66%;}
  .col-s-12 {width: 100%;}
}
@media only screen and (min-width: 768px) {
  /* For desktop: */
  .col-1 {width: 8.33%;}
  .col-2 {width: 16.66%;}
  .col-3 {width: 25%;}
  .col-4 {width: 33.33%;}
  .col-5 {width: 41.66%;}
  .col-6 {width: 50%;}
  .col-7 {width: 58.33%;}
  .col-8 {width: 66.66%;}
  .col-9 {width: 75%;}
  .col-10 {width: 83.33%;}
  .col-11 {width: 91.66%;}
  .col-12 {width: 100%;}
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Code to link to a css file

A

link rel=”stylesheet” href=”mystyle.css”

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

Object oriented constructor method

A
class Person:
  def \_\_init\_\_(self, name, age):
    self.name = name
    self.age = age
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Object oriented getter and setter methods

A
def setHeight(self, hei):
    self.height = hei
def getHeight(self):
    return self.height
#MP
person.setHeight("190")
print(person.getHeight())
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What does inheritance mean

A

Inheritance is when a child class inherits all the attributes and methods from another class which then becomes the super class.

class Student(Person):
  def \_\_init\_\_(self, fname, lname, year):
    super().\_\_init\_\_(fname, lname)
    self.graduationyear = year

x = Student(“Mike”, “Olsen”, 2019)

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

What does instantiation mean

A

Instantiation means an instance of a class or the object that belongs to a class.

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

What does polymorphism mean

A

It is when there are multiple different outputs resulting from the same input so it depends on what the input is measuring, like the lengths of an array.

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

What does encapsulation mean

A

It means the attributes in a class can only be altered within itself using setter and getter methods.

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

Creating a table in SQL withe restricted choice

A

CREATE TABLE user (
username VARCHAR(20) NOT NULL PRIMARY KEY,
password VARCHAR(20) NOT NULL,
gender VARCHAR NOT NULL CHECK(gender = “male” or gender = “female”),
nickname VARCHAR(20) NOT NULL,
FOREIGN KEY nickname REFERENCES score(nickname)
);

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

Weak and strong entities

A

A strong entity is not dependent of any other entity.

A weak entity is dependent on a strong entity to ensure its existence

Weak entities are represented by dotted lines in the entity relationship diagram.

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

What does a binary search look like?

A
def BinarySearch1(searchlist1,goal):
 found = False
 startpos = 0
 endpos = len(searchlist) -1

#print (“Endpos at beginning = “,endpos)

while (startpos <= endpos) and found == False:
middle = (startpos+endpos)//2 #Integer Division
if searchlist[middle] == goal:
found = True
elif searchlist[middle] smaller than goal:
startpos = middle + 1
else:
endpos = middle -1

if found == True:
print(“Match has been found at position”,middle)
else:
print(“Goal not found”)

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

What does a bubble sort look like?

A

def bubbleSort(beforeName, beforeScore):

for outer in range (len(beforeScore) -1,0,-1):
    for inner in range(outer):
        if beforeScore[inner]>beforeScore[inner+1]:
            temp = beforeScore[inner]
            tempName = beforeName[inner]
            beforeScore[inner] = beforeScore[inner+1]
            beforeName[inner] = beforeName[inner+1]
            beforeScore[inner+1] = temp
            beforeName[inner+1] = tempName

print(beforeScore, beforeName)

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

What does an insertion sort look like?

A

def insertionSort(beforeName, beforeScore):

for index in range(1,len(beforeScore)):
    currentval = beforeScore[index]
    currentName = beforeName[index]
    position = index
    while position > 0 and (beforeScore [position-1] > currentval):
        beforeScore[position] = beforeScore[position-1]
        beforeName[position] = beforeName[position-1]
        position = position - 1
    beforeScore[position] = currentval
    beforeName[position] = currentName

print(beforeScore, beforeName)