SQL Server - table design

Asked By morphius
20-Nov-09 07: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
)
SQL Server
(1)
Uniqueidentifier
(1)
Date
(1)
Enteringthe
(1)
Technician
(1)
Databases
(1)
Datatypes
(1)
Identity
(1)
  Dan Guzman replied to morphius
20-Nov-09 08: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/
  Jay replied to morphius
20-Nov-09 09: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)
  morphius replied to Dan Guzman
20-Nov-09 09:50 AM
I am leaning towards using composite keys. Would this yield better
performance compared to uniqueidentifier?
  Jay replied to morphius
20-Nov-09 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.
  Dan Guzman replied to morphius
20-Nov-09 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/
Create New Account
help
SQL Server error '80040e31': please help me! SQL Server I have the following problem in a Win 2000 Server + SQL Server 2000 environment and I hope somewhat can help me to resolve it (after many days detail relation with "id" as foreign key. The fields of the "detail" table are: - id0: uniqueidentifier, primary key (newid() IsRowGuide = Yes); - id: uniqueidentifier, foreign key; - progr: bigint, Identity = Yes; - data: smalldatetime
Let sql server or client application create uniqueidentifier? SQL Server Before I get too deep into my project, should I let sql server create all of my uniqueidentifiers and fill in all of the default column values? or All of the columns that have default values will always have current values if used. SQL Server Programming Discussions SQL Server (1) System.Guid.NewGuid (1) Uniqueidentifier (1) Stored procedure (1
Writing clr table value types SQL Server How do you write a table value type in CLR [vb]? SQL Server Programming Discussions SQL Server 2000 (1) SQL Server 2005 (1) SQL Server (1) Uniqueidentifier (1) Stored procedure (1) CREATE VIEW (1) Google is
SQL Server: 8, 421 max transactions per second? SQL Server i was wondering what an upper limit for SQL Server performance i should be looking at. i googled and found this article for SQL Server 2000: http: / / www.sqlmag.com / Article / ArticleID / 16087 / sql_server_16087.html 505, 302.77 transactions per
Replication between SQL server and SQL express ???? SQL Server Dear all, I try to setup a replication between a database TEST on a server myServer into an SQL express database myDB on a Vista office PC machine. For that I define my SQL server to be a publisher of my database TEST and then on my Client PC