![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
How can I create an Interbase table with an autoincrement field in SQL? |
#3
| |||
| |||
|
|
How can I create an Interbase table with an autoincrement field in SQL? What should I change in this query for example: |
|
CREATE TABLE names ( ID INT, name CHAR(30), PRIMARY KEY(ID) ); |
#4
| |||
| |||
|
|
How can I create an Interbase table with an autoincrement field in SQL? What should I change in this query for example: |
#5
| |||
| |||
|
|
How can I create an Interbase table with an autoincrement field in SQL? =Why do you want to be a bad programmer? Auto-increment Oh, you mean faking a sequential file's positional record number, so I can reference the **physical** storage location? Sure, if I want to lose all the advantages of an abstract data model, SQL set oriented programming, carry extra data and destroy the portability of code! More and more programmers who have absolutely no database training are being told to design a database. They are using GUIDs, IDENTITY, ROWID and other proprietary auto-numbering "features" in SQL products to imitate either a record number (sequential file system mindset) or OID (OO mindset) since they don't know anything else. snip |
#6
| |||
| |||
|
|
--CELKO-- wrote: How can I create an Interbase table with an autoincrement field in SQL? =Why do you want to be a bad programmer? Auto-increment Oh, you mean faking a sequential file's positional record number, so I can reference the **physical** storage location? Sure, if I want to lose all the advantages of an abstract data model, SQL set oriented programming, carry extra data and destroy the portability of code! More and more programmers who have absolutely no database training are being told to design a database. They are using GUIDs, IDENTITY, ROWID and other proprietary auto-numbering "features" in SQL products to imitate either a record number (sequential file system mindset) or OID (OO mindset) since they don't know anything else. snip I think that you are either generalising wildly or misunderstand the OP. Let's think of a common problem: defining an order number for a sales order. You might have a table such as this: orders( order_number int, customer_order_number varchar, order_status int, customer_account_number int ) I can't think of any good reason not to use order_number as an auto increment primary key. Nothing else can be a key, and there is no advantage to getting the middle tier or (!) client to define it. Despite the fact that I agree with your sentiment regarding programmers hacking database design, I have to say that I regard auto increment as a useful way of simplifying middle tier database calls and avoiding the need for recalculating (e.g.) order_number before every insert. John |
#7
| |||
| |||
|
|
John <no@email> wrote --CELKO-- wrote: How can I create an Interbase table with an autoincrement field in SQL? =Why do you want to be a bad programmer? Auto-increment Oh, you mean faking a sequential file's positional record number, so I can reference the **physical** storage location? Sure, if I want to lose all the advantages of an abstract data model, SQL set oriented programming, carry extra data and destroy the portability of code! More and more programmers who have absolutely no database training are being told to design a database. They are using GUIDs, IDENTITY, ROWID and other proprietary auto-numbering "features" in SQL products to imitate either a record number (sequential file system mindset) or OID (OO mindset) since they don't know anything else. snip I think that you are either generalising wildly or misunderstand the OP. Let's think of a common problem: defining an order number for a sales order. You might have a table such as this: orders( order_number int, customer_order_number varchar, order_status int, customer_account_number int ) I can't think of any good reason not to use order_number as an auto increment primary key. Nothing else can be a key, and there is no advantage to getting the middle tier or (!) client to define it. Despite the fact that I agree with your sentiment regarding programmers hacking database design, I have to say that I regard auto increment as a useful way of simplifying middle tier database calls and avoiding the need for recalculating (e.g.) order_number before every insert. John What about the idea of having a multiple primary key on customer_account_number and order_date? Or, if you want to track the status history of the order, have a primary key for (customer_account_number,order_date,order_status)? I personally would never use a surrogate key for the primary key (except in rare occasions). Although, I might make it a unique column for customer interaction purposes (i.e. "When you contact us, just tell the support service represantative your trouble ticket number is 123456"). The problem with the scenario you present is that the same order could be entered more than once (each with a different order_number). I've seen this happen, and I've seen it cost a company a good percent of their gross profit in one quarter. Todd |
#8
| |||
| |||
|
|
Let's think of a common problem: defining an order number for a sales |
#9
| |||
| |||
|
|
We handled the situation by providing a sequence number for each message to assure uniqueness. We could have handled it by adding the |
#10
| |||
| |||
|
|
We handled the situation by providing a sequence number for each message to assure uniqueness. We could have handled it by adding the milliseconds to the time-stamp, but that was benchmarked as taking more CPU cycles than the auto-increment. That one is weird; I have never seen a timestamp that was slower than an auto-increment. They are both derived from hardware and the timeclock in in main storage, while the auto-increment counts are often attached to schema information tables so they have to be read into storage. Also, doesn't your clock go finer than milliseconds? The FIPS rules say you have to have at least five decimal places in the seconds. |
![]() |
| Thread Tools | |
| Display Modes | |
| |