3 Replies - 264 Views - Last Post: 26 August 2013 - 10:10 AM Rate Topic: -----

#1 kyle_denney  Icon User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 138
  • Joined: 10-August 12

Being Normal But Updating Record Issue

Posted 26 August 2013 - 09:33 AM

Hello,

I am trying to figure out how to set up my schema for an SQL Server database. I would like to figure out how to update a record or insert a record given certain criteria and how to distinguish the difference and when to use what one.

My tables are normalized to the third normal form with a distinct primary key and foreign key relationship for each table.

My example is this:

Lets say I had a computer whose name was DELLCOMP and I had a table with the computer list in it with all the computers on my network. Then I had another table with the CD drive information which had a foreign key tying the CD drive information back to the computer. Let say for instance I had two of the same CD/DVD drives in the CD table because the computer had two exact same drives installed.

If the only difference was the primary key id how do I know which record to update. Lets say upon first entry all I can input is the computer id the CD drive's belong to and the name of the CD drive. Perhaps I don't have the drive letter associated with the two drives yet. How do I distinguish between the two records to update one but not the other, for instance, if I get the drive letter later of one but not the other. And how do I tell when I should insert instead of update.

I think splitting the table out might be an option or maybe changing the PK to something other than an ID but I am not sure on this. Any ideas would be helpful. Thanks!

This post has been edited by kyle_denney: 26 August 2013 - 09:35 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Being Normal But Updating Record Issue

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9363
  • View blog
  • Posts: 35,172
  • Joined: 12-June 08

Re: Being Normal But Updating Record Issue

Posted 26 August 2013 - 09:40 AM

Quote

Let say for instance I had two of the same CD/DVD drives in the CD table.

So those are not the same thing, right? Model/serial numbers are unique and what not..



Quote

If the only difference was the primary key id how do I know which record to update.

... update, what?

Quote

I distinguish between the two records to update one but not the other.

Both drives would have a unique id in.. I don't know.. a parts table?

Quote

And how do I tell when I should insert instead of update.

You will have to clarify what you are looking for and updating.
Was This Post Helpful? 0
  • +
  • -

#3 kyle_denney  Icon User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 138
  • Joined: 10-August 12

Re: Being Normal But Updating Record Issue

Posted 26 August 2013 - 10:07 AM

I mentioned what I would like to update. Lets say at first I want to enter both records into a database that have the same model number but I do not know what the drive letter is. I know nothing else about the drives except the PC they belong to and the model number. I insert both of those into the database. How do I update only one of those records with the drive letter? Am I thinking of this in the wrong light? Thanks!
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9363
  • View blog
  • Posts: 35,172
  • Joined: 12-June 08

Re: Being Normal But Updating Record Issue

Posted 26 August 2013 - 10:10 AM

One solution would be to give each drive a unique (physical) id. Slap a barcode or something on it so you know which is which when you pull them out. The alternative would be to use foreign key information.. in the case of that example use the computer's ID it was found in.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1