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.
Author |
Topic |
sapator
Constraint Violating Yak Guru
462 Posts |
Posted - 2014-02-08 : 14:56:13
|
Hello.I must create a DB and my problem is this:Table GeolocationTable Cost_CenterTable GeoToCostTable InkToCostTable Ink_TypeCost_Center can reference 2 or more Geolocations So i made the intermediate table GeoToCostInk must reference a Cost_Center so i made the intermediate table InkToCost The problem i am facing is how will determine in what Geolocation an Ink can be because the Cost_Center can be in more than one Geolocation.I am thinking of making a composite PK on table InkToCost with PK Cost_Center id and GeoToCost id.So i will know that an ink of type A has a Cost_Center name X that resides on Geolocation GeoA.I have 2 problems here.1st if this the way to go and second, how will i reference this query.Do i need to add also GeoToCost id on ink_Type table?I haven't made the tables yet so i don't have a schema but if required i will make test tables.Anyhow FK's are Geolocation --> FK GeoToCost <-- Cost_Center ,Cost_Center --> InkToCost <-- Ink_Type ,So do i need also Cost_Center --> InkToCost(PK Cost_Center_id, GeoToCost_id) <-- Ink_Type ?Of can i just put on InkToCost the Cost_Center_id,Geolocation_id and don't make a composite PK?Thanks. |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2014-02-11 : 02:45:04
|
As I understand its enough if you just include GeoToCost in InkToCost as each record in GeoToCost represents a relationship of cost center to ONE particular location. Then you'll be able to link ink to cost center and also to its location.------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
sapator
Constraint Violating Yak Guru
462 Posts |
Posted - 2014-02-11 : 21:03:45
|
Thanks. I will try and if i have any problems i will let you know. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2014-02-12 : 00:27:46
|
ok..let me know how you got on------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
|
|
|