• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 453
  • Last Modified:

MS SQL Server 2008 Data integrity FK NULL

I'm going to be real lame here and ask an easy question.. I think.. this is to make
up for later when I ask a reeeeaaalllllly hard question and get really fussy.  Be warned!

You see I have successfully created a couple of tables.  "Table _1 " is now called
"Sales_Rep" as I have saved it thus refreshing the name on the tab.  I need
"seller" to be a foreign key referring to the primary key "name" of Sales_Rep but
I think it is okay if it is null?  hmm.. yes.  I think an unsold Automobile (Table_2) can
be in the database.

Maybe I have to click that relationship jobbie?
seller.jpg
0
kayvey
Asked:
kayvey
  • 18
  • 3
2 Solutions
 
HoggZillaCommented:
Question: Can a FK be NULL
Answer: Yes: A FOREIGN KEY constraint does not have to be linked only to a PRIMARY KEY constraint in another table; it can also be defined to reference the columns of a UNIQUE constraint in another table. A FOREIGN KEY constraint can contain null values; however, if any column of a composite FOREIGN KEY constraint contains null values, verification of all values that make up the FOREIGN KEY constraint is skipped. To make sure that all values of a composite FOREIGN KEY constraint are verified, specify NOT NULL on all the participating columns.
Question: How do I define a FK relationship in SQL
Answer: Several Options: http://msdn.microsoft.com/en-us/library/ms177463.aspx
 
0
 
kayveyAuthor Commented:
I'm in touchy feely Windoze moode.  I dont know where to type the SQL right now.  Can I right click on something instead?
0
 
kayveyAuthor Commented:
I press buttons dwive me kwayzey
FK-wazyzey.jpg
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
kayveyAuthor Commented:
I'm not trying to make this hard.  I think we are close this one.
0
 
kayveyAuthor Commented:
That's better. I saved with right names now. Automobile.seller must be Sales_Rep.name.  seller FK to
Sales_RepPK.name.  
sellerFKname.jpg
0
 
kayveyAuthor Commented:
Now you see Sales_Rep.  Sales_Rep (s) he have name(S)
namePK.jpg
0
 
kayveyAuthor Commented:
oh oh., bad danger. soooo many windoze i never asked for
badPKdanger.jpg
0
 
kayveyAuthor Commented:
Okay I done now with kwayzey nonsense?  i have no idea.
PKFKdone.jpg
0
 
kayveyAuthor Commented:
Can you read that? It is Foreign Key Relationships Diagalog woohaw.

-Tables and Columns Specifica
       Foreign Key Base Table         Automobile
       Foreign Key Columns             seller
       Primary/Unique Key Base Ta Sales_Rep
       Primary/Unique Key Column  name
-Identity
   (Name)                                       FK_Automobile_Sales_Rep
   
0
 
kayveyAuthor Commented:
this is kwayzey awful slow
0
 
kayveyAuthor Commented:
I mean my stooopid awful old puter running Vista.. I save I save It confused.
0
 
kayveyAuthor Commented:
Tables and Columns make me mad.  Can't change Forieng key table.

oopsie!   got it backards?
ornery.jpg
combobulate.jpg
0
 
kayveyAuthor Commented:
oooh nooo!!! bad saving.. agnrgy windowze..won't let me save now.. make
stupid system32 textfile
saveProb.jpg
systemTxt.jpg
0
 
kayveyAuthor Commented:
nooooo!  not stupid cancle!! this disaster bad wrong bad wrong wrong bad bad bad rowong
worong wong wong wrong wrong
cancel.jpg
0
 
kayveyAuthor Commented:
THIS LAST STRAW DISASTER NONSENSE>  HOW TO DROP DANG TABLES??
exErr.jpg
0
 
HoggZillaCommented:
You are hilarious. I have no idea where you are now, sorry. What can I do to help. I thought you had it there but it seems you and your database are not on good terms?
0
 
kayveyAuthor Commented:
Did I do the FK right?
0
 
kayveyAuthor Commented:
Okay I guess it's fine.  Now how do I populate the tables?
0
 
kayveyAuthor Commented:
I got this stupid thing called Power Shell.. maybe that's where I type SQL? I don't want to lookup nonsense.Where is stupid spreadsheet type view of data in fields?
powerShell.jpg
0
 
HoggZillaCommented:
In SQL Server management Studio, behind your above console screen, Right Click on the table and select Open Table. There you can type values into the columns directly.
0
 
kayveyAuthor Commented:
It's not Open table.  It's Edit top 200 lines..

allrighty then.  I guess that'll do it.  Thank you, sir.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 18
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now