So I’m designing a database using MS SQL with an invoices table and a clients table. My clients table looks something like:
--------------------------------
Client ID | Name | Phone | Address | City | State | Zip
________________________________
Where the client ID is a GUID primary key.
My invoices table looks something like:
--------------------------------
Invoice ID | Client ID | Date/Time | Price
________________________________
Where the invoice ID would be a number (starting at say, 1000) and auto-incrementing by 1.
Is this ok, or bad practice? I just don’t want my invoices to be printing out with invoice # 336868de-7778-41fc-ae7f-662f76d5615a....
I personally don’t see a reason to ever use a GUID – if I need something auto-generated, identity it is. So to answer your question, that’s perfectly fine. And as Martin commented, I’d consider using an auto-number for your customer ids as well.