|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Today @ 8:53 AM
Points: 6,351,
Visits: 5,363
|
|
SQL2K
Starting with the following tables.
SalesExecutive SalesExecutiveID Name
Outcome OutcomeID Outcome
Source SourceID Source
Model ModelID Model
ContactType ContactTypeID ContactType
Contact ContactID ContactDate ContactName SalesExecutiveID OutcomeID SourceID ModelID ContactTypeID
I have contacts that are linked to other tables by ID's. To start with all the tables will be empty and a Web app will create all the data as and when necessary.
Now I want to introduce locations. A location is a code varchar(10) and currently consists of 6 numeric digits where the first three are always zeros. There are approx 140 locations with last three digits consisting of any number in the range 1-999 and are not consecutive. The number of locations will increase and normally no number is reused.
All the data in the tables has to separated by location as each location has it's own values and a location may not see or use each other's data.
Each location can have thousands of contacts per year and any number of SalesExecutive,Outcome,Source,Model,ContactType linked to them.
Any ideas?
Far away is close at hand in the images of elsewhere. Anon.
|
|
|
|
|
SSC-Addicted
      
Group: General Forum Members
Last Login: Today @ 11:56 AM
Points: 454,
Visits: 418
|
|
I am not sure what your question is? However, the only idea I can surmise is you are missing a Locations table in your list and the location code "LocationID" should be a fixed char(6) field and not a varchar(10). Then you contacts table should have a LocationID foreign key to identify the location of each contact.
Ron K.
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." -- Martin Fowler
|
|
|
|
|
SSC-Dedicated
           
Group: General Forum Members
Last Login: Today @ 2:32 PM
Points: 32,906,
Visits: 26,792
|
|
What? Oh? OH? OOOOOHHHHH!!! BWAAAA-HAAAAAA-HAAAAA! WHOOOOO-IIIIEEEEEE! SNNOORRRTTT! Now, THAT's funny, David!!!! OMIGOD!!! I CAN'T QUIT LAUGHING!!!! TOO FUNNY, MR BURROWS!!!! OH! PHHHT! GOTTA CHANGE MY DEPENDS!!! HAAAA-HAAAA-HAAAA!!! LMAO!!!!
Well done, David... I'll clear some of my PM's... we gotta have a laugh together about this one!
--Jeff Moden "RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row".
First step towards the paradigm shift of writing Set Based code: Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."
For better, quicker answers on T-SQL questions, click on the following... http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following... http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Today @ 8:53 AM
Points: 6,351,
Visits: 5,363
|
|
I am not sure what your question is?
Sorry Ron. I'll try to meke it clearer 
Thanks for the reply :)
The data is separate by Location, ie the ContactID will unique to the Location as will be the SalesExecutive,Outcome etc
Whilst using LocationID (and I left out a Location table on purpose as I did not want to constrain any design yet) will separate the Contacts by Location and by inference all it's associated data. I will need to retrieve all the SalesExecutive, Outcome etc for a specific Location irrespective of Contacts as a SalesExecutive may exists for a Location but not be referenced.
The question is how to alter the design for performance and scalability.
Three things occured to me
1. A database per Location (140+ databases!!!) 2. One database with tables repeated for each Location (partitioned views with 140+ tables!!!) 3. Unique range of ID's per Location
As I stated it is about performance and scalability.
byw the Location of varchar(10) is fixed due to third party system, however the last 3 digits (1-999) is still in operation, but who knows for how long! it could change
Far away is close at hand in the images of elsewhere. Anon.
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Today @ 8:53 AM
Points: 6,351,
Visits: 5,363
|
|
What? Oh? OH? OOOOOHHHHH!!! BWAAAA-HAAAAAA.....
Sorry Jeff...
Did not know if you were laughing at me 
or at my question 
or was it that I actually posted one
Far away is close at hand in the images of elsewhere. Anon.
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Friday, February 15, 2013 6:29 PM
Points: 1,326,
Visits: 1,265
|
|
Hi David, Like I see you have snowflake data model, If I really understood, for me, I will create a table location(locationId, locationName) and each table will have the location id as foreign key. Regards, Ahmed
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Friday, February 15, 2013 6:29 PM
Points: 1,326,
Visits: 1,265
|
|
Hi David, check this link a good site for database design http://www.databaseanswers.org/data_models/index.htm Regards, Ahmed
|
|
|
|
|
SSC-Dedicated
           
Group: General Forum Members
Last Login: Today @ 2:32 PM
Points: 32,906,
Visits: 26,792
|
|
David Burrows (11/28/2007)
What? Oh? OH? OOOOOHHHHH!!! BWAAAA-HAAAAAA..... Sorry Jeff... Did not know if you were laughing at me  or at my question  or was it that I actually posted one 
Oh, bugger... I'm so sorry, David... my mind is really warped... I thought you were making fun of a series of threads that are responsible for the current inflamed crease in my gray-matter. My most sincere appologies.
--Jeff Moden "RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row".
First step towards the paradigm shift of writing Set Based code: Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."
For better, quicker answers on T-SQL questions, click on the following... http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following... http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
|
|
|
|
|
SSC-Dedicated
           
Group: General Forum Members
Last Login: Today @ 2:32 PM
Points: 32,906,
Visits: 26,792
|
|
A location is a code varchar(10) and currently consists of 6 numeric digits where the first three are always zeros.
First, leading zeros tend to be for display and I probably wouldn't store the location ID's that way. I'd make the location either an INT, or possibly, because of the limited number of possibilities, a SMALLINT. I'd add a calculated column to the location table to display the SMALLINT value with the required leading zeros. It'll save on some storage space and possibly improve performance, a bit.
As for the Executive and Contact tables...
I'm not sure that I would separate these... I believe I'd put Executives in the Contact table with a flag that indicated they were executives. In either case, I'm not real sure how you would handle a Contact being promoted to an Executive status. I'd have to think about that.
I'm a bit confused about ModelID and SourceID in the Contact table. It would appear that each contact is somehow responsible for a given Model or set of Model's from different sources. That's quite a bit of denormalization in that if, say, a given Contact was female and changed her name at the marriage event, you would have to change that name on more than one row. I believe that a cross-reference table between Contacts and Models would suite better. It does add some complexity as 3rd normal form has the tendency to do, but I believe it will be better in the long run in so far as maintainability goes.
Also, if Models can come from different sources, I'd add the SourceID to the Model table and include that in the cross-reference table I spoke of... that would be a source of great relief for the normalization of the Contact table.
Once that were accomplished, then I believe there would be no need for separate tables or databases for each Location. Simply add the LocationID to most of the tables. Properly indexed, I don't believe performance or scalability will even come close to being an issue.
--Jeff Moden "RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row".
First step towards the paradigm shift of writing Set Based code: Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."
For better, quicker answers on T-SQL questions, click on the following... http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following... http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Today @ 8:53 AM
Points: 6,351,
Visits: 5,363
|
|
My most sincere appologies
No need Jeff :)
I thought you were making fun of a series of threads that are responsible for the current inflamed crease in my gray-matter
Not me... but if you send me the thread I'll give it a damn good try... lol ;)
Seriously though, this is a question I am struggling with and since your 'the man' on scalabilty I'd really appreciate any thoughts you may have. I am worried that this database will start off fine and rapidly 'go south' in a big way
p.s. Thanks for the feedback Ahmed :)
Far away is close at hand in the images of elsewhere. Anon.
|
|
|
|