ATAR Notes: Forum

VCE Stuff => VCE Technology => VCE Mathematics/Science/Technology => VCE Subjects + Help => VCE Computing: Data Analytics => Topic started by: methodsboy on October 15, 2009, 07:03:35 pm

Title: Foreign Key
Post by: methodsboy on October 15, 2009, 07:03:35 pm
hey every1, the IT threads have been very quite lately.
does anyone know what a foreign key is? and is it the same as a secondary key?
Title: Re: Foreign Key
Post by: ell on October 15, 2009, 07:29:37 pm
A foreign key is a key in a table that references a field from another table.

E.g. let's say a company takes orders, and they have a Customers table and an Orders table - the Orders table may use the CustomerID field from the Customer table to help uniquely identify an order.

It's separate to a secondary key, which is a different concept that I don't think you need to know for VCE IT.
Title: Re: Foreign Key
Post by: methodsboy on October 15, 2009, 10:19:17 pm
ohhh..ive used that many times..except i had no idea that that's what it was called. LOL!
thanks
Title: Re: Foreign Key
Post by: excal on October 20, 2009, 02:48:31 am
@ ell - I've never heard of the concept of the secondary key before - is it any different from a candidate key?

For those who are interested, a candidate key is a field that would be suitable as a primary key field in a table but, for whatever reason, is not.

(both of these you won't need to know for IT:A)
Title: Re: Foreign Key
Post by: cobby on October 20, 2009, 07:21:47 am
@ ell - I've never heard of the concept of the secondary key before - is it any different from a candidate key?

For those who are interested, a candidate key is a field that would be suitable as a primary key field in a table but, for whatever reason, is not.

(both of these you won't need to know for IT:A)
Do you have an example of where a candidate key may be used Excal?
Title: Re: Foreign Key
Post by: ell on October 20, 2009, 12:34:57 pm
@ ell - I've never heard of the concept of the secondary key before - is it any different from a candidate key?

From what I understand, there's secondary indexes - simply a secondary way to access records - which either use candidate keys or a "nonkey with duplicate values" (straight from textbook). The secondary indexes that use candidate keys are called secondary keys, so they are the same thing as a candidate key essentially.

@cobby: You'll start to look at candidate keys when you do normalization of relations into the different normal forms, which you'll learn more about at uni if you decide to do IT.
Title: Re: Foreign Key
Post by: excal on October 20, 2009, 11:46:15 pm
@ ell - I've never heard of the concept of the secondary key before - is it any different from a candidate key?

For those who are interested, a candidate key is a field that would be suitable as a primary key field in a table but, for whatever reason, is not.

(both of these you won't need to know for IT:A)
Do you have an example of where a candidate key may be used Excal?

Candidate keys are generally not used - they're just used to describe fields that are suitable as primary keys, but are not (very simplified explanation). You won't need to look at this unless you  study IT at university...

A more complicated explanation is here: http://en.wikipedia.org/wiki/Candidate_key

(the term 'tuple' in database theory is pretty much a row / record in practice)