Database Relationship
Sam or anyone else,
FYI: I'm trying to set up a photo album project "live", similar to the one in chapter 14. I set up two tables on the SQL Server on Godaddy.com: Album and Picture.
QUESTIONS: Has anyone set up tables and relationships on a live server? If so, how did you manage to set up the table relationship as depicted on page 498?
1) I am unable to use the Database Diagram in VWD nor SQL Server Mgmt Studio. Both places, I get the message "... A member of the db_owner role must use the database diagramming functionality ... "
2) Therefore, I try to use the SQL Server Web Admin provided by Godaddy. But when I try to setup the relationship it doesn't accept it as follows:
- click Album table
- click New relationships
- choose Picture as Foreign Key table
- choose Id (primary key on Album table) and AlbumId (foreign key on Picture table)
- click Create
>>> Error message: There are no primary or candidate keys in the ref table 'dbo.Picture' that match the referencing column list on the foreign key 'FK_Picture_Album". ... "
3) However, when I try to set up the relationship in reverse order, select any column from the Album table and choose the Id (primary key on the Foreign table Picture), it allows the relationship to be set up. But this doesn't seem correct. It's like (using the example on page 498), connecting the Id on Album to Id on Pictures. We don't want this, we want Id on Album to connect to PhotoAlbumId on Pictures.
CONCLUSION: I probably spent nearly two hours on this particular point because it seems backward. After further research, I am now pretty convinced that the Primary Key table and Foreign Key table are presented backwards in the Relationships section. I confirmed that the relationship holds its referential integrity based on what I expected by trying to delete items from each table. Based on this, it seems "incredible", but the PK and FK tables are listed backwards on the Godaddy SQL Server Web Admin.
I wrote this for two reasons: Maybe someone can correct me (but I can't see where) ... also, perhaps it'll save someone else some time and hair wrangling if in this same situation ... good luck.
|