Jump to content

total newbie question


astralaaron

Recommended Posts

Just wondering why you need a primary_key, what difference does it make haveing a primary key.like if I had a field "id" what can you do if it is a primary key that you cannot do if it is not a primary key..?does this question make sence?

Link to comment
Share on other sites

The way I see it, every table needs at least one column which always has a value, never changes and whose value is unique for each record (OK I stole those three things from a book!). It makes sense though. If you have a table and a row has no values then when you try to look something up it will be very confusing for you and for your db. If you have some data that change regularly (like most data) and you try to look it up after a month of it changing, you will have no way to compare or understand what the data is refering to. Finally if you have two rows with exactly the same data in each column, again, when you come to look up the data, both rows will be returned and again it will be confusing.Also if you are going to relate two tables to each other then you need to have a 'hook'. The primary key is a hook that you can say is the one point in common between two tables.

Link to comment
Share on other sites

The way I see it, every table needs at least one column which always has a value, never changes and whose value is unique for each record (OK I stole those three things from a book!). It makes sense though. If you have a table and a row has no values then when you try to look something up it will be very confusing for you and for your db. If you have some data that change regularly (like most data) and you try to look it up after a month of it changing, you will have no way to compare or understand what the data is refering to. Finally if you have two rows with exactly the same data in each column, again, when you come to look up the data, both rows will be returned and again it will be confusing.Also if you are going to relate two tables to each other then you need to have a 'hook'. The primary key is a hook that you can say is the one point in common between two tables.
thanks, I understand a little better atleast!
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...