English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

What's the difference between primary, composite and foreign keys and when are they chosen?

Also, why are queries important to database users?

2007-07-06 00:13:13 · 3 answers · asked by little zebulon 4 in Computers & Internet Programming & Design

3 answers

It's more involved than you can answer in a paragraph. Take a look at this article: http://www.databasedev.co.uk/primary_foreign_keys.html

it explains the differences well. Queries are important to DB users because thats how information is retrieved from the database.

SELECT name, pay FROM employees WHERE pay > 8

is an example of a query that would return a list of employee's names and their hourly pay if they make more than $8/hr. from a database table.

2007-07-06 00:33:18 · answer #1 · answered by Anonymous · 0 0

primary keys are the important one in database....which is used for making an ordered list.....which'ill help ti ident..a indivi..one frm bulk queries.....foreign keys r nothing but they are the primary key of an query at the same time it'll be a part of an another query...

2007-07-06 07:28:10 · answer #2 · answered by rajumon 2 · 0 0

Good thing you didn't add "Candidate keys" to the mix, because that's a tough one to answer IMHO. Then we get into whole idea of FD and stuff.

Primary key is one attribute in a tuple that identifies such tuple as unique to other tuples in the same relation.

Composite key is a primary key that happens to be using a combination of two or more attributes instead of one.

Foreign key is less used as implementation but still important in design and writing correct queries; it is a key of either one of above type in attribute, but instead of identifying itself this refers to another tuple of any relation as having a relationship to the tuple that has it; a foreign key in one and a primary key at the other side.

2007-07-06 08:12:21 · answer #3 · answered by Andy T 7 · 0 0

fedest.com, questions and answers