Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Uniqueness of index PRIMARY is violated
Message
From
10/10/1998 09:40:06
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00144393
Message ID:
00145648
Views:
42
>I use a naming convention that I picked up from Drew Speedie, and I've been quite happy with it:
>
>Members table:
>All fields are prefixed with mbr
>Primary key: mbr_pk
>Candidate key: mbr_name_ck
>
>Dues table:
>All fields are prefixed with due
>Foreign key: due_mbr_fk

One thing I like and the other I don't. I like the suffix idea - if you maybe remember the Inverse Hungarian Notation thread, some time Summer'97, you may know what I mean. We've spilled lots of bytes over the subject at the time.

Prefixing the fields with an abbreviation of an alias doesn't suit me at all. The main reason is not that it looks like what Cobol people do (it's only an aesthetic issue), it's the sorting. I specifically want my, say, customer code to be called "custcode" no matter where it appears. Many of my customers have existing codes for their customers, line items etc from previous apps, and I often need to import these tables. The length of these fields usually fits mine, but quite often it doesn't. I've built a routine to assign a public var to lengths of these, and store it in a config.dbf of a kind, and my tables generating routine looks like this
 Create Table Customers (cust c(s_lCust), ...
Create Table Invoices (InvNo C(10), cust c(s_lCust)...
In order to achieve this, I have a custom table with descriptions of all the fields in all of the tables. Now it's easy to assign such a variable to certain fields - I have an index on FieldName, and in a browse they line up one after another. If they were prefixed, it would be a nightmare to track.

Another reason for not prefixing is for the quick local copy routines, where some fields from one table (or a cursor derived from one or more tables) have to be stuffed into another table. Scatter/Gather memvar (or Name) does it without much coding. Actually, adding another field into a cursor automatically propagates its contents to another table in such a context, without any coding at all. (To OOP purists: I said local) If they were prefixed, I'd have to do lots of "Select ... mbr_cust as dzw_cust" or write lengthy Insert ...values ... (mbr_this, mbr_that, ...).

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform