Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 12»»

Database Design Question Expand / Collapse
Author
Message
Posted Tuesday, November 27, 2007 2:59 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 6:49 AM
Points: 7,087, Visits: 6,894
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.

Post #426244
Posted Tuesday, November 27, 2007 3:30 PM


SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Thursday, July 10, 2014 1:33 PM
Points: 457, Visits: 476
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
Post #426618
Posted Tuesday, November 27, 2007 5:32 PM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Today @ 8:17 AM
Points: 36,944, Visits: 31,448
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."

(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #426663
Posted Wednesday, November 28, 2007 2:34 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 6:49 AM
Points: 7,087, Visits: 6,894
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.

Post #426768
Posted Wednesday, November 28, 2007 2:36 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 6:49 AM
Points: 7,087, Visits: 6,894
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.

Post #426770
Posted Wednesday, November 28, 2007 2:51 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Tuesday, August 12, 2014 9:52 AM
Points: 1,326, Visits: 1,288
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
Post #426777
Posted Wednesday, November 28, 2007 3:04 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Tuesday, August 12, 2014 9:52 AM
Points: 1,326, Visits: 1,288
Hi David,
check this link a good site for database design http://www.databaseanswers.org/data_models/index.htm
Regards,
Ahmed
Post #426784
Posted Wednesday, November 28, 2007 7:07 AM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Today @ 8:17 AM
Points: 36,944, Visits: 31,448
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."

(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #426869
Posted Wednesday, November 28, 2007 7:38 AM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Today @ 8:17 AM
Points: 36,944, Visits: 31,448
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."

(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #426887
Posted Wednesday, November 28, 2007 7:43 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 6:49 AM
Points: 7,087, Visits: 6,894
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.

Post #426893
« Prev Topic | Next Topic »

Add to briefcase 12»»

Permissions Expand / Collapse