Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Database Design Question


Database Design Question

Author
Message
David Burrows
David Burrows
SSCertifiable
SSCertifiable (8K reputation)SSCertifiable (8K reputation)SSCertifiable (8K reputation)SSCertifiable (8K reputation)SSCertifiable (8K reputation)SSCertifiable (8K reputation)SSCertifiable (8K reputation)SSCertifiable (8K reputation)

Group: General Forum Members
Points: 7970 Visits: 9431
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.


Ron Kunce
Ron Kunce
SSC-Addicted
SSC-Addicted (470 reputation)SSC-Addicted (470 reputation)SSC-Addicted (470 reputation)SSC-Addicted (470 reputation)SSC-Addicted (470 reputation)SSC-Addicted (470 reputation)SSC-Addicted (470 reputation)SSC-Addicted (470 reputation)

Group: General Forum Members
Points: 470 Visits: 496
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
Jeff Moden
Jeff Moden
SSC-Forever
SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)

Group: General Forum Members
Points: 45329 Visits: 39936
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.
Although they tell us that they want it real bad, our primary goal is to ensure that we dont actually give it to them that way.
Although change is inevitable, change for the better is not.
Just because you can do something in PowerShell, doesnt mean you should. Wink

Helpful Links:
How to post code problems
How to post performance problems
Forum FAQs
David Burrows
David Burrows
SSCertifiable
SSCertifiable (8K reputation)SSCertifiable (8K reputation)SSCertifiable (8K reputation)SSCertifiable (8K reputation)SSCertifiable (8K reputation)SSCertifiable (8K reputation)SSCertifiable (8K reputation)SSCertifiable (8K reputation)

Group: General Forum Members
Points: 7970 Visits: 9431
I am not sure what your question is?


Sorry Ron. I'll try to meke it clearer Blush

Thanks for the reply Smile

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.


David Burrows
David Burrows
SSCertifiable
SSCertifiable (8K reputation)SSCertifiable (8K reputation)SSCertifiable (8K reputation)SSCertifiable (8K reputation)SSCertifiable (8K reputation)SSCertifiable (8K reputation)SSCertifiable (8K reputation)SSCertifiable (8K reputation)

Group: General Forum Members
Points: 7970 Visits: 9431
What? Oh? OH? OOOOOHHHHH!!! BWAAAA-HAAAAAA.....


Sorry Jeff...

Did not know if you were laughing at me Crying

or at my question Sad

or was it that I actually posted one Blink


Far away is close at hand in the images of elsewhere.

Anon.


SQL_ABD
SQL_ABD
Ten Centuries
Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)

Group: General Forum Members
Points: 1332 Visits: 1349
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
SQL_ABD
SQL_ABD
Ten Centuries
Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)

Group: General Forum Members
Points: 1332 Visits: 1349
Hi David,
check this link a good site for database design http://www.databaseanswers.org/data_models/index.htm
Regards,
Ahmed
Jeff Moden
Jeff Moden
SSC-Forever
SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)

Group: General Forum Members
Points: 45329 Visits: 39936
David Burrows (11/28/2007)
What? Oh? OH? OOOOOHHHHH!!! BWAAAA-HAAAAAA.....


Sorry Jeff...
Did not know if you were laughing at me Crying
or at my question Sad
or was it that I actually posted one Blink


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.
Although they tell us that they want it real bad, our primary goal is to ensure that we dont actually give it to them that way.
Although change is inevitable, change for the better is not.
Just because you can do something in PowerShell, doesnt mean you should. Wink

Helpful Links:
How to post code problems
How to post performance problems
Forum FAQs
Jeff Moden
Jeff Moden
SSC-Forever
SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)

Group: General Forum Members
Points: 45329 Visits: 39936
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.
Although they tell us that they want it real bad, our primary goal is to ensure that we dont actually give it to them that way.
Although change is inevitable, change for the better is not.
Just because you can do something in PowerShell, doesnt mean you should. Wink

Helpful Links:
How to post code problems
How to post performance problems
Forum FAQs
David Burrows
David Burrows
SSCertifiable
SSCertifiable (8K reputation)SSCertifiable (8K reputation)SSCertifiable (8K reputation)SSCertifiable (8K reputation)SSCertifiable (8K reputation)SSCertifiable (8K reputation)SSCertifiable (8K reputation)SSCertifiable (8K reputation)

Group: General Forum Members
Points: 7970 Visits: 9431
My most sincere appologies


No need Jeff Smile

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 Wink

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 Smile


Far away is close at hand in the images of elsewhere.

Anon.


Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search