Archive for the ‘SQL’ Category
MySQL Server Has Gone Away problem solved
I was just looking at RobsNotebook.com and came across a really good solution to a common problem with WordPress.
Lately, I have been getting a lot of error messages on my blog that said “MySQL server has gone away.” I looked through the Godaddy support forums hoping to find a solution. Unfortunately, I did not.
But then I found RobsNotebook.com and they had a page dedicated to this problem. It turns out that it is caused by the SQL connection being open for too long. Essentially, WordPress does not close the connection every time.
Godaddy’s (or insert your own host here) configuration of MySQL tells it to time out after a certain period, and that can happen in the middle of your call to the database.
RobsNotebook.com has provided a php file that you use in wordpress and just replace your existing file. He made it so easy that it takes only about 5 minutes to put in the solution.
P.S. I verified that the php page was correctly coded and had no “funny business” on it, but as the file could change at any time, it is always good to look through it for yourself whenever you download and use PHP from the net.
Things to Know Before You Graduate – For Computer Science Majors
As a computer science major, there are many things you should know before you graduate. To land a job, it is important that you have a broad base of knowledge when it comes to computer science. Below, I have compiled a list of some key things to know before you graduate.
By the way, these are mainly from questions that were asked during my interview with Avanade last week.
- SQL Transaction
- The combination of several SQL statements into one atomic group. It allows for an all or nothing approach.
- SQL User Defined Functions
- Functions that are run on the SQL server that are created by the user of the DBMS.
- SQL View
- A view appears like any database table, and can be operated on just like any table, but is actually a portion of a database table.
- CREATE VIEW myview AS
- SELECT name, age
- FROM students
- WHERE age = 5
- Definition of Inner Join
- A join of two tables that returns records for which there is a matching value in the field on which the tables are joined.
- Definition of Outer Join
- A table join in which rows from one table are included in the result set, even if they don’t contain values that match those in the other table.
- Normalization
- Decreases the amount of data
- Decreases the load on the server and can increase performance
- Going beyond 1NF can introduce logic errors when inserting/updating/deleting records
- Acid Properties
- In databases, ACID stands for Atomicity, Consistency, Isolation, and Durability. They are considered to be the key transaction processing features of a database management system, or DBMS. Without them, the integrity of the database cannot be guaranteed.
- Linked Lists vs. Arrays
- Duh! Just think inserts, deletes, and sorting and the complexity involved in these transactions
- Interface
- An interface is a description of a set of methods that conforming implementing classes must have.
- Only non static methods and static final variables can be defined in the interface.
- Abstract Classes
- A class in which some of the functions are not implemented.
- Characteristics of Object Orientated Programming
- Inheritance
- Encapsulation
- Abstraction
- Polymorphism
- Access Modifiers
- Public – Visible to all classes
- Protected – Visible to the class they belong to and to any sub-classes
- Private – Visible to the class they belong to
- Software Development Methodologies
- In the traditional waterfall methodology, first comes the analysis phase, then the design phase, followed by the implementation phase, with testing completing the process. The team that does each phase is different and there may be a management decision point at each phase transition. This methodology is called the waterfall methodology because each phase flows naturally into the next phase like water over a series of falls.
- The spiral methodology fixes some of the problems introduced by the waterfall methodology. The spiral methodology still has the four phases. A little time is initially spent in each phase followed by several iterations over all four phases.
- Sorting Algorithms
- Bubble Sort
- The array of values to be sorted is divided into two partitions: the partition of sorted values and that of unsorted values.
- In each step of bubble sort, the smallest element found so far in the unsorted partition moves up, and it is appended to the end of the sorted partition.
- The sorting proceeds until the elements in the unsorted partition are exhausted.
- Selection Sort
- The selection sort works by selecting the smallest unsorted item remaining in the list, and then swapping it with the item in the next position to be filled. The selection sort has a complexity of O(n2).
- You have a Floor variable (which identifies the index of your first unsorted position in your array, and you have a minimum index variable that will point to whichever position is lowest so far. Once the remaining portion of the array is looked at, the floor variable and the minimum index variable are swapped.
- Bubble Sort
SQL Statements – Create a database
As mentioned in earlier posts, SQL is an extremely important part of web development. Below is instruction on how to create a database in SQL. This is based on a Linux MySQL DBMS, but it should work (or be very similar) on other versions of SQL as well.
- Log in to MySQL by typing:
- mysql -u username -p
- If you wish to see existing databases, type:
- show databases;
- Now, we can create the new database. We will call the database “thisDatabase:”
- create database thisDatabase;
- Then we need to assign permissions to a user. This can be a new or an existing user. We will use the user name, terry. The password will be set to password:
- GRANT ALL ON thisDatabase.* TO terry@localhost IDENTIFIED BY “password”;
Congratulations, your database is set up. This is something that you will need to use if you are installing a content management system like WordPress, Drupal, or Xoops. You can read more about creating a database by clicking here.


