Posts Tagged ‘example’

Mysql-Don’t Overuse Artificial Primary Keys

Thursday, July 24th, 2008

Artificial primary keys are nice because they can make the schema less volatile. If we stored geography information in the US based on zip code, say, and the zip code system suddenly changed we’d be in a bit of trouble. On the other hand, many times there are perfectly fine natural keys. One example would be a join table for many-to-many relationships. What not to do:
CREATE TABLE posts_tags (
relation_id int UNSIGNED NOT NULL AUTO_INCREMENT,
post_id int UNSIGNED NOT NULL,
tag_id int UNSIGNED NOT NULL,
PRIMARY KEY(relation_id),
UNIQUE INDEX(post_id, tag_id)
);

Not only is the artificial key entirely redundant given the column constraints, but the number of post-tag relations are now limited by the system-size of an integer. Instead one should do:
CREATE TABLE posts_tags (
post_id int UNSIGNED NOT NULL,
tag_id int UNSIGNED NOT NULL,
PRIMARY KEY(post_id, tag_id)
);

Search engine optimization-The Way Backlinks Are Counted

Friday, July 18th, 2008

Similar to the history of your site, the history of the links to your site have gained importance. As was noted in Google’s patent application #20050071741 titled, “Information retrieval based on historical data,” links, like sites, gain weight over time. This point was further clarified in the latest update as sites with longstanding links gained strength while sites with many new links did not see significant ground gained. The “sandbox” on links is functioning in fractions in that after a period of time a link will gain part of it’s weight, after a bit longer, it will gain more, etc. (the exact length of time is of course a closely guarded secret by Google and likely changes as their algorithm does). This means your link building today won’t create any substantial effect on your Google rankings until months down the road.

Additionally, the relevancy of links to your site is still important however Google’s ability to determine relevancy appears to have improved. Pages no longer have to containing the exact keyword phrases to be relevant but rather have to be from related industries. For example, a link to an SEO site from a web design site would be considered relevant even though the keywords on the page are not specifically related to SEO.

Natural links have gained weight over unnatural links. Links that are contained within content areas of a page will be weighted more strongly that links that appear alone or in a directory-style (like reciprocal links pages) as they are considered more natural. When you are having links built to your site try to get them placed within the content (within the description portion of your reciprocal link for example). Also, in link building you will want to insure you’re varying the terms of your anchor text. Creating hundreds of links with identical anchor text will quickly be detected as a link building effort (i.e. not natural) and thus will carry little weight. Different anchor text for your links will appear more natural and thus will have a more positive impact on your rankings.

Searching For Multiple Words

Tuesday, July 15th, 2008

Use the word OR to require that one or the other term be found in the search results. For example, giants OR baseball (include a space on each side of the OR) lists sites containing “giants” or “baseball.” You can combine AND, OR, AND NOT by using parentheses. For example, to find documents that contain the word giants but not either the word baseball or football type giants NOT (baseball OR football). You could also type this giants -(baseball OR football). Note: You cannot begin a search with a “-” term. You must put some other search term first.

Searching For Required Words

Tuesday, July 15th, 2008

You can type the plus sign (+) or the word AND before a word to require that it be found in all of the search results. For example, giants +baseball (include a space between the first word and the + symbol) or giants AND baseball returns all listings that contain “baseball” and “giants” but not necessarily together.

Creating an HTML Marquee / Scrolling Text

Monday, July 14th, 2008

The HTML MARQUEE tag is used to scroll text across a web page and is only supported by Microsoft Internet Explorer.

You can change the marquee background color, width, the number of times your message will scroll, and the speed that your text scrolls, by adding the following attributes within your MARQUEE tag.

BGCOLOR=”#CCCCCC” - background color

LOOP - Determines how many times the text will scroll. -1 is indefinite and will continuously scroll. You can set this to whatever you’d like.

SCROLLAMOUNT - Determines the speed your text will scroll.

WIDTH - Determines the width of your marquee.

<MARQUEE bgcolor=”#CCCCCC” loop=”-1″ scrollamount=”2″ width=”100%”>Example Marquee</MARQUEE>

If you would rather have your text bounce back and forth, place the following code within your HTML. This example displays the marquee with linked text.

<MARQUEE behavior=”alternate” scrollamount=”2″ bgcolor=”#CCCCCC” width=”100%”><A HREF=”http://www.yourdomain.com”>This is an example of bouncing text</A>.</MARQUEE>

Changing an HTML Web Page Link Color

Monday, July 14th, 2008

You can change the color of an individual HTML web page link by adding a font tag in front of your linked text.

Example Code:

<A HREF=”http://www.blog.tryangled.com”><FONT COLOR=”#FF0000″>Your Link</FONT></A>

Enlarging Text Size within a Web Page

Sunday, July 13th, 2008

Although you can enlarge web page  text with the FONT tag, you also use the BIG tag.

The BIG tag is used to increase the size of your font. You can add additional BIG tags, side by side, to increase your font size even further. For each additional BIG tag you use, your font size will increase.

HTML Code:

<BIG>Your Text</BIG>

Browser View:

Your Text

HTML Code:

<BIG><BIG>Your Text</BIG></BIG>

Browser View:

Your Text

The BIG tag can be used in place of the FONT tag, as they both perform the same task.

Example Font Tag:

<FONT size=”3″>

Php:Variable variables

Tuesday, July 1st, 2008

A variable variable looks like this: $$var

So, if $var = ‘foo’ and $foo = ‘bar’ then $$var would contain the value ‘bar’ because $$var can be
thought of as $’foo’ which is simply $foo which has the value ‘bar’.

Variable variables sound like a cryptic a useless concept, but they can be useful sometimes. For
example, if we have a configuration file consisting of configuration directives and values in this
format:

foo=bar
abc=123
Then it is very easy to read this file and create corresponding variables:

<?php
$fp = fopen(’config.txt’,'r’);
while(true) {
$line = fgets($fp,80);
if(!feof($fp)) {
if($line[0]==’#’ || strlen($line)<2) continue;
list($name,$val)=explode(’=',$line,2);
$$name=trim($val);
} else break;
}
fclose($fp);
?>
Along the same lines as variable variables, you can create compound variables and variable
functions.

<?php
$str = ‘var’;
$var_toaster = “Hello World”;
echo ${$str.’_toaster’};
$str(); // Calls a function named var()
${$str.’_abc’}(); // Calls a function named var_abc()
?>

SEO:Concept-based searching

Monday, June 30th, 2008

Excite used to be the best-known general-purpose search engine site on the Web that relies on concept-based searching.  It is now effectively extinct.

Unlike keyword search systems, concept-based search systems try to determine what you mean, not just what you say.  In the best circumstances, a concept-based search returns hits on documents that are “about” the subject/theme you’re exploring, even if the words in the document don’t precisely match the words you enter into the query.

How did this method work?  There are various methods of building clustering systems, some of which are highly complex, relying on sophisticated linguistic and artificial intelligence theory that we won’t even attempt to go into here.  Excite used to a numerical approach.  Excite’s software determines meaning by calculating the frequency with which certain important words appear.  When several words or phrases that are tagged to signal a particular concept appear close to each other in a text, the search engine concludes, by statistical analysis, that the piece is “about” a certain subject.

For example, the word heart, when used in the medical/health context, would be likely to appear with such words as coronary, artery, lung, stroke, cholesterol, pump, blood, attack, and arteriosclerosis.  If the word heart appears in a document with others words such as flowers, candy, love, passion, and valentine, a very different context is established, and a concept-oriented search engine returns hits on the subject of romance.

SEO:Keyword Searching

Monday, June 30th, 2008

This is the most common form of text search on the Web.  Most search engines do their text query and retrieval using keywords.

What is a keyword, exactly?  It can simply be any word on a webpage.  For example, I used the word “simply” in the previous sentence, making it one of the keywords for this particular webpage in some search engine’s index.   However, since the word “simply” has nothing to do with the subject of this webpage (i.e., how search engines work), it is not a very useful keyword.   Useful keywords and key phrases for this page would be “search,” “search engines,” “search engine methods,” “how search engines work,” “ranking” “relevancy,” “search engine tutorials,” etc.  Those keywords would actually tell a user something about the subject and content of this page.

Unless the author of the Web document specifies the keywords for her document (this is possible by using meta tags), it’s up to the search engine to determine them.  Essentially, this means that search engines pull out and index words that appear to be significant.  Since since engines are software programs, not rational human beings, they work according to rules established by their creators for what words are usually important in a broad range of documents.  The title of a page, for example, usually gives useful information about the subject of the page (if it doesn’t, it should!).  Words that are mentioned towards the beginning of a document (think of the “topic sentence” in a high school essay, where you lay out the subject you intend to discuss) are given more weight by most search engines.   The same goes for words that are repeated several times throughout the document.

Some search engines index every word on every page. Others index only part of the document.

Full-text indexing systems generally pick up every word in the text except commonly occurring stop words such as “a,” “an,” “the,” “is,” “and,” “or,” and “www.”  Some of the search engines discriminate upper case from lower case; others store all words without reference to capitalization.