Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 column reference to multiple tables

Author  Topic 

nimbus
Starting Member

2 Posts

Posted - 2011-05-23 : 00:12:16
i have been hitting the wall for a long time. hopefully someone can enlighten me. here's an example of the scenario.

say i have the following tables

LAPTOP_CATALOG
- ProductID (primary key)
- Brand
- Model
- Weight
- ScreenSize
- Processor
- RAM
- HDD

SOFTWARE_CATALOG
- ProductID (primary key)
- Name
- HardwareReq
- Description

when a student raise a loan request for either a laptop or software, it creates a record in REQUEST table.

REQUEST
- RequestID
- StudentID
- RequestDate
- ProductID
- Status

The problem here is... the ProductID can be from either LAPTOP or SOFTWARE catalog. How do i enforce the referential integrity constraint such that REQUEST.ProductID must exist in LAPTOP_CATALOG.ProductID or SOFTWARE_CATALOG.ProductID?

i can probably split the request to LAPTOP_REQUEST and SOFTWARE_REQUEST. But the actual scenario i have is much complex, and i think it's not feasible to do this.

TIA.

ahmeds08
Aged Yak Warrior

737 Posts

Posted - 2011-05-23 : 00:18:11
is the productid in SOFTWARE CATALOG foreign key???inheriting from the product table
Go to Top of Page

nimbus
Starting Member

2 Posts

Posted - 2011-05-23 : 00:25:28
hi ahmeds08. there is no PRODUCT table.

because laptop and software hold different essential attributes, thats why i have split them into separate tables.

** i updated the first post slightly..
Go to Top of Page
   

- Advertisement -