I am a newbie.. please.. tell me what is this.

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
claws
Forum Commoner
Posts: 73
Joined: Tue Jun 19, 2007 10:54 am

I am a newbie.. please.. tell me what is this.

Post by claws »

Hi.. every one.

in a database table. for every field there are 3 options available
1. primary
2. Index
3. Unique.

kindly tell me
1. what does each means??
2.how they differ from each other.??
3. can each of the above 3 be applied to any no. of fileds??
4. for a field can we apply all the 3??

really i am very confused with these...

any links to articles will be appriciated...
[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1 wrote:2. Use descriptive subjects when you start a new thread. Vague titles such as "Help!", "Why?" are misleading and keep you from receiving an answer to your question.
[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1 wrote:11. Please use proper, complete spelling when posting in the forums. AOL Speak, leet speak and other abbreviated wording can confuse those that are trying to help you (or those that you are trying to help). Please keep in mind that there are many people from many countries that use our forums to read, post and learn. They do not always speak English as well as some of us, nor do they know these aberrant abbreviations. Therefore, use as few abbreviations as possible, especially when using such simple words.

Some examples of what not to do are ne1, any1 (anyone); u (you); ur (your or you're); 2 (to too); prolly (probably); afaik (as far as I know); etc.
Rovas
Forum Contributor
Posts: 272
Joined: Mon Aug 21, 2006 7:09 am
Location: Romania

Post by Rovas »

They refer to the type of key you want to set for your table. But if you don' t know want a key is hard to explain you here want you should now. Get a good book or search for tutorial design database, table keys, etc. Read them first then if you still have questions put them here.
User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

Post by CoderGoblin »

Very quickly...

You can only have 1 primary field and this should be whenever possibly an integer field. This column is both unique and indexed.

Indexed fields are those fields you normally search on (joined to other tables etc). Again it is more efficient to use integers whenever possible. Indexes speed up access to the information contained within as the system knows roughly where each value is quicker. Making all your columns indexed does not speed the information retrieval. You need to make sure only those columns you are searching with are indexed. Indexed columns do not need to be unique.

Uniques fields are those columns where all values must be unique with no repetitions within the same column.

Hope that helps but for more information look up some articles. Google is your friend.
User avatar
ReverendDexter
Forum Contributor
Posts: 193
Joined: Tue May 29, 2007 1:26 pm
Location: Chico, CA

Post by ReverendDexter »

I want to drive this point home, though it was brought up already:

If you are totally new to the concepts of primary/foriegn keys, unique fields, and indices, stop whatever you're developing, and either go get a book or take a class in database design. These are not concepts that I would suggest just trying to glean from what you can learn via blind shots with google. Getting a book or class will ensure that you cover *all* of the basics, and don't miss something very important just because you didn't know to search for it.
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

I always recommend a book over internet tutorials / blog articles. There are way too many people out there who think they know what they're talking about, but don't. For example:

Here is how you write a php contact form! :roll:

Code: Select all

<?php echo $_GET['error_msg']; ?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>">
   <input type="text" name="name" value="<?php echo $_POST['name']; ?>">
   <input type="submit" value="submit">
</form>
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

The Ninja Space Goat wrote:I always recommend a book over internet tutorials / blog articles. There are way too many people out there who think they know what they're talking about, but don't. For example:

Here is how you write a php contact form! :roll:

Code: Select all

<?php echo $_GET['error_msg']; ?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>">
   <input type="text" name="name" value="<?php echo $_POST['name']; ?>">
   <input type="submit" value="submit">
</form>
Hehe. Thank God for the forums, or they'd never have anyone to tell them.
Post Reply