logo

table design

morphius posted on Friday, November 20, 2009 7:07 AM

Based on the table info below I need some suggestion(whatever is needed e.g
datatypes) to design this wherein the work order will always be unique. The
challenge is that there are multiple standalone systems in the field with the
same databases used by technicians. If the work order number is inserted
between standalone systems, I want to be able to uniquely identify the same
work order number even if it is on separate standalone system(laptop).

work_order table
(
work_order_number_id
work_order_name
company_name_id
technician_id
date_completed
)

work_breakdown table
(
work_breakdown_id
work_breakdown_name
work_description
work_order_number_id
)
reply


One method is to add another column (e.g.

Dan Guzman replied to morphius on Friday, November 20, 2009 8:37 AM

One method is to add another column (e.g. site_id) and use the composite of
site_id and work_order_number_id as the primary key.

Another approach is to use a uniqueidentifier data type for
work_order_number_id so that you can use GUID values as the surrogate
primary key.

--
Hope this helps.

Dan Guzman
SQL Server MVP
http://weblogs.sqlteam.com/dang/
reply

IMHO GUIDS suck if people ever have to use them, how do you like enteringthe

Jay replied to morphius on Friday, November 20, 2009 9:19 AM

IMHO GUIDS suck if people ever have to use them, how do you like entering
the Microsoft key when you do an install?

You just need a two-part key

work_order_origin       char(5),
work_order_number    identity (1,1)
reply

I am leaning towards using composite keys.

morphius replied to Dan Guzman on Friday, November 20, 2009 9:50 AM

I am leaning towards using composite keys. Would this yield better
performance compared to uniqueidentifier?
reply

How many rows are you talking about?

Jay replied to morphius on Friday, November 20, 2009 11:44 AM

How many rows are you talking about? If it is under 100,000 per year and
you are using a reasonable PK, performance of the composite key should not be
an issue.
reply

If the work_order_number is incremental, I would expect the composite

Dan Guzman replied to morphius on Friday, November 20, 2009 11:13 PM

If the work_order_number is incremental, I would expect the composite key
approach to perform better than a single random GUID.  You'll get less
fragmentation and better locality of reference.  It will be a closer call if
you assign uniqueidentifier values using NEWSEQUENTIALID.

--
Hope this helps.

Dan Guzman
SQL Server MVP
http://weblogs.sqlteam.com/dang/
reply

 

Didn't Find The Answer You Were Looking For?

View SQL Server Posts   Ask A New Question

EggHeadCafe has experts online right now that may know the answer to your question.  We pay them a bonus for answering as many questions as they can.  So, why not help them and yourself by becoming a member (free) and ask them your question right now?
Create Account & Ask Question In Live Forum

Previous SQL Server conversation.

SQL Server Compact Edition    SQL Server Clients    SQL Server Connect    SQL Server Data Mining    SQL Server Data Warehouse    SQL Server DTS    SQL Server FullText    SQL Server MSDE    SQL Server OLAP    SQL Server Replication    SQL Server Reporting Services    SQL Server Security    SQL Server    SQL Server Setup    SQL Server Tools    SQL Server Clustering    SQL Server Programming    SQL Server XML    SQL Server New Users    SQL Server Integration Services   




  $1000    Adam Houldsworth - $187  |  Jonathan VH - $139  |  Kirtan Patel - $117  |  F Cali - $116  |  Huggy Bear - $88  |  more Neado  |  Free Icons  |  Privacy  |   (c) 2010