Test 1 Flashcards
Example of a having clause with a WHERE
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;
Two ways to execute a query in php
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))
Characteristics of a linked or doubly linked list?
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
Examples of media queries
/* 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%;} }
Code to link to a css file
link rel=”stylesheet” href=”mystyle.css”
Object oriented constructor method
class Person: def \_\_init\_\_(self, name, age): self.name = name self.age = age
Object oriented getter and setter methods
def setHeight(self, hei): self.height = hei
def getHeight(self): return self.height
#MP person.setHeight("190") print(person.getHeight())
What does inheritance mean
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)
What does instantiation mean
Instantiation means an instance of a class or the object that belongs to a class.
What does polymorphism mean
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.
What does encapsulation mean
It means the attributes in a class can only be altered within itself using setter and getter methods.
Creating a table in SQL withe restricted choice
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)
);
Weak and strong entities
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.
What does a binary search look like?
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”)
What does a bubble sort look like?
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)