RE: Hungarian Notation [Was Re: Too many aliases]
2011/08/08 10:25 -0400, Jerry Schwartz I was a reluctant convert, and still don't use Hungarian notation consistently; but in something like MS Access, where you might want to associate a label with a field, things like lblCompany and txtCompany make a lot of sense. I forgot this--my VB teacher consistently recommended it. -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org
Re: Hungarian Notation [Was Re: Too many aliases]
On Saturday 06 August 2011 10:58:43 am Jan Steinman wrote: From: Johnny Withers joh...@pixelated.net http://en.wikipedia.org/wiki/Hungarian_notation Well, I can see this being useful in assembly language, or strongly-typed, non-OO languages. But I was asking specifically about SQL! When will this EVER make sense:? select * from intCustomers; We know from context that customers is a table and it makes no sense at all to prefix a type to it in order to make the obvious more clear. I guess we could have: select * from viewCustomers; or select * from tblCustomers: But really? My personal convention is that table names are plural. Foreign indexes have the table name as a prefix. For example. create table customers ( id integer, index. companies_idinteger, namevarchar(20) ); Obviously, companies_id is a reference to the id field in a table called companies. Just my $.02, but any comments are welcome. The original Hungarian notation... was invented by Charles Simonyi... who later became Chief Architect at Microsoft. Ugh. That explains a lot! The only time I let types intrude on names is with booleans, which I try to name with a state-of-being verb, such as has_paid, is_member, has_children, etc. On Thu, Aug 4, 2011 at 9:41 AM, Mike Diehl mdi...@diehlnet.com wrote: Well, while we're on the subject of SQL style, can anyone tell me why I'm always seeing people prefixing the name of a table with something like tbl? You can't do anything about the length of your life, but you can do something about its width and depth. -- H. L. Mencken Jan Steinman, EcoReality Co-op -- Take care and have fun, Mike Diehl. -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org
RE: Hungarian Notation [Was Re: Too many aliases]
I was a reluctant convert, and still don't use Hungarian notation consistently; but in something like MS Access, where you might want to associate a label with a field, things like lblCompany and txtCompany make a lot of sense. Regards, Jerry Schwartz Global Information Incorporated 195 Farmington Ave. Farmington, CT 06032 860.674.8796 / FAX: 860.674.8341 E-mail: je...@gii.co.jp Web site: www.giiresearch.com -Original Message- From: Martin Gainty [mailto:mgai...@hotmail.com] Sent: Saturday, August 06, 2011 10:02 PM To: j...@bytesmiths.com; mysql@lists.mysql.com Subject: RE: Hungarian Notation [Was Re: Too many aliases] Jan- the upside is you dont have to look up a variable to know what type it is: zVariable is Null termed string bVariable is boolean nVariable is an Integer fVariable is a float dVariable is a double.. cVariable is a char Martin __ easy peasy..Shawshank Redemption Subject: Hungarian Notation [Was Re: Too many aliases] From: j...@bytesmiths.com Date: Sat, 6 Aug 2011 09:58:43 -0700 To: mysql@lists.mysql.com From: Johnny Withers joh...@pixelated.net http://en.wikipedia.org/wiki/Hungarian_notation The original Hungarian notation... was invented by Charles Simonyi... who later became Chief Architect at Microsoft. Ugh. That explains a lot! The only time I let types intrude on names is with booleans, which I try to name with a state-of-being verb, such as has_paid, is_member, has_children, etc. On Thu, Aug 4, 2011 at 9:41 AM, Mike Diehl mdi...@diehlnet.com wrote: Well, while we're on the subject of SQL style, can anyone tell me why I'm always seeing people prefixing the name of a table with something like tbl? You can't do anything about the length of your life, but you can do something about its width and depth. -- H. L. Mencken Jan Steinman, EcoReality Co-op -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/mysql?unsub=mgai...@hotmail.com -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org
Re: Hungarian Notation [Was Re: Too many aliases]
2011/08/08 00:13 -0600, Mike Diehl Well, I can see this being useful in assembly language, or strongly-typed, non-OO languages. But I was asking specifically about SQL! We know from context that customers is a table and it makes no sense at all to prefix a type to it in order to make the obvious more clear. I suspect it makes the most sense in weakly typed languages, and, therefore, quite useless in table names. TAble names are not found in the same context as field names, and the same name may be used for both table and field in the table--field names, on the other hand, In the PL1 (and scripting-language) tradition, although in the table definition there is fairly narrow description of the type, much implicit conversion is allowed. It is also in the PL1 tradition that operators yield values of some vague type ('+' yields number, '||' yields character: no general operator overloading), but with all the conversion it seldom is clear to the user what a generated field s exact type is: even which numeric type, even which character type, with what length. Then there is room for tacking type descriptions onto names. 2011/08/08 00:13 -0600, Mike Diehl My personal convention is that table names are plural. Foreign indexes have the table name as a prefix. To me a table is like an array, and therefore I make it singular: invoice, say, is an array of invoices, and invoice [ 5 ] is invoice 5. My plurals are for counts of things; if invoice is a table, then select count(*) as invoices from invoice -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org
Re: Hungarian Notation [Was Re: Too many aliases]
I despise this sort of notation, and have instead adopted what have cheerfully named Hungarian Suffix notation, the reason being Signal-To-Noise ratio. Instead of prefacing everything with some form of prefix, just do the opposite: Customer_tbl Customer_Dead_boo Customer_DOB_date Customer_qs (that means Query Select) Customer_qu (that means Query Update) Customer_qd (that means Query Delete) CustomerOrders_tbl Customer_frm (a form that opens the Customer table; could involve subforms, but in that case they are named Customer_Orders_fsub, Customer_Payments_fsub, and so on. Easy to read, obvious the intent, and easily sortable. Just my opinion. Arthur
Re: Hungarian Notation [Was Re: Too many aliases]
I join you Arthur. That Hungarian notation is despicable (though I love listening to that language, it is different). I don't find it necessary for a column name to tell me its type. But I do like the ability to have all database objects (table, column, trigger, index, fk, views, procedures, etc.) sortable and searchable. I use a prefix though. My prefix is a number for one reason: Ease of communication with stuff. A schema is assigned to a range of numbers. Sounds old fashioned? Cobolish? So? My 2c. David. - Original Message - From: Arthur Fuller fuller.art...@gmail.com To: Martin Gainty mgai...@hotmail.com Cc: mysql@lists.mysql.com mysql@lists.mysql.com Sent: Sun Aug 07 19:03:43 2011 Subject: Re: Hungarian Notation [Was Re: Too many aliases] I despise this sort of notation, and have instead adopted what have cheerfully named Hungarian Suffix notation, the reason being Signal-To-Noise ratio. Instead of prefacing everything with some form of prefix, just do the opposite: Customer_tbl Customer_Dead_boo Customer_DOB_date Customer_qs (that means Query Select) Customer_qu (that means Query Update) Customer_qd (that means Query Delete) CustomerOrders_tbl Customer_frm (a form that opens the Customer table; could involve subforms, but in that case they are named Customer_Orders_fsub, Customer_Payments_fsub, and so on. Easy to read, obvious the intent, and easily sortable. Just my opinion. Arthur
Re: Too many aliases
2011/08/04 10:21 -0500, Johnny Withers http://en.wikipedia.org/wiki/Hungarian_notation On Thu, Aug 4, 2011 at 9:41 AM, Mike Diehl mdi...@diehlnet.com wrote Well, while we're on the subject of SQL style, can anyone tell me why I'm always seeing people prefixing the name of a table with something like tbl? Yeah, but why perpetuate such a thing in a language that has type (at least 'table' is distinct)? BCPL had at all no type. -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org
Hungarian Notation [Was Re: Too many aliases]
From: Johnny Withers joh...@pixelated.net http://en.wikipedia.org/wiki/Hungarian_notation The original Hungarian notation... was invented by Charles Simonyi... who later became Chief Architect at Microsoft. Ugh. That explains a lot! The only time I let types intrude on names is with booleans, which I try to name with a state-of-being verb, such as has_paid, is_member, has_children, etc. On Thu, Aug 4, 2011 at 9:41 AM, Mike Diehl mdi...@diehlnet.com wrote: Well, while we're on the subject of SQL style, can anyone tell me why I'm always seeing people prefixing the name of a table with something like tbl? You can't do anything about the length of your life, but you can do something about its width and depth. -- H. L. Mencken Jan Steinman, EcoReality Co-op -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org
Re: Too many aliases
It's simple... ttwwadi is the only reason I assume. Sent from my iPad On Aug 5, 2011, at 2:39 PM, (Hal�sz S�ndor) h...@tbbs.net wrote: 2011/08/04 10:21 -0500, Johnny Withers http://en.wikipedia.org/wiki/Hungarian_notation On Thu, Aug 4, 2011 at 9:41 AM, Mike Diehl mdi...@diehlnet.com wrote Well, while we're on the subject of SQL style, can anyone tell me why I'm always seeing people prefixing the name of a table with something like tbl? Yeah, but why perpetuate such a thing in a language that has type (at least 'table' is distinct)? BCPL had at all no type. -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/mysql?unsub=joh...@pixelated.net -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org
RE: Hungarian Notation [Was Re: Too many aliases]
Jan- the upside is you dont have to look up a variable to know what type it is: zVariable is Null termed string bVariable is boolean nVariable is an Integer fVariable is a float dVariable is a double.. cVariable is a char Martin __ easy peasy..Shawshank Redemption Subject: Hungarian Notation [Was Re: Too many aliases] From: j...@bytesmiths.com Date: Sat, 6 Aug 2011 09:58:43 -0700 To: mysql@lists.mysql.com From: Johnny Withers joh...@pixelated.net http://en.wikipedia.org/wiki/Hungarian_notation The original Hungarian notation... was invented by Charles Simonyi... who later became Chief Architect at Microsoft. Ugh. That explains a lot! The only time I let types intrude on names is with booleans, which I try to name with a state-of-being verb, such as has_paid, is_member, has_children, etc. On Thu, Aug 4, 2011 at 9:41 AM, Mike Diehl mdi...@diehlnet.com wrote: Well, while we're on the subject of SQL style, can anyone tell me why I'm always seeing people prefixing the name of a table with something like tbl? You can't do anything about the length of your life, but you can do something about its width and depth. -- H. L. Mencken Jan Steinman, EcoReality Co-op -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/mysql?unsub=mgai...@hotmail.com
Re: Too many aliases
2011/08/03 12:46 +0200, Rik Wasmus But the main thing is it helps to distinguish tables in joins having the same table more then once (and of course results from subqueries etc.): SELECT first.* FROM tablename first LEFT JOIN tablename second ONfirst.some_id = second.some_id AND first.id != second.id WHERE second.id IS NULL Well, yes, here it is needful. But it seems to me from most of the examples that people here post, that they have the idea that it is the style always to use one-letter aliases, whether it is helpful or not. Now I do not do this, but I often see examples where a field for one purpose has in one table one name, and in another table another, slightly different, name, and then, too, I see alias used, although, in this case, no table name at all is needed. (I like to use the same field name in all tables where it has the same function.) -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org
RE: Too many aliases
I agree. I use the same column name in all tables where it has the same function - but I consistently add a suffix or prefix. And yes, it is the old fashion way David. -Original Message- From: h...@tbbs.net [mailto:h...@tbbs.net] Sent: Thursday, August 04, 2011 8:26 AM To: r...@grib.nl Cc: mysql@lists.mysql.com Subject: Re: Too many aliases 2011/08/03 12:46 +0200, Rik Wasmus But the main thing is it helps to distinguish tables in joins having the same table more then once (and of course results from subqueries etc.): SELECT first.* FROM tablename first LEFT JOIN tablename second ONfirst.some_id = second.some_id AND first.id != second.id WHERE second.id IS NULL Well, yes, here it is needful. But it seems to me from most of the examples that people here post, that they have the idea that it is the style always to use one-letter aliases, whether it is helpful or not. Now I do not do this, but I often see examples where a field for one purpose has in one table one name, and in another table another, slightly different, name, and then, too, I see alias used, although, in this case, no table name at all is needed. (I like to use the same field name in all tables where it has the same function.) -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/mysql?unsub=dle...@us.univision.com -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org
RE: Too many aliases
-Original Message- From: David Lerer [mailto:dle...@us.univision.com] Sent: Wednesday, August 03, 2011 10:25 AM To: mysql@lists.mysql.com Subject: RE: Too many aliases I rarely use aliases (unless rarely required in self-join queries). Yes, the column names may be longer this way, but easy to refer to and easy to communicate (by specifying a table number). I wonder what others think about it. [JS] Back when I was trying to fit as much code on a punch-card as possible, the languages only supported short names, and the terminals ran at 10cps, every keystroke was precious. Now I routinely pay the price of extra keystrokes for readability: not just with things such as column names, but with parentheses and the like as well. Like you, I only use aliases when necessary. If I want brain-teasers, I'll do a crossword puzzle. But that's just me. Regards, Jerry Schwartz Global Information Incorporated 195 Farmington Ave. Farmington, CT 06032 860.674.8796 / FAX: 860.674.8341 E-mail: je...@gii.co.jp Web site: www.giiresearch.com -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org
Re: Too many aliases
Well, while we're on the subject of SQL style, can anyone tell me why I'm always seeing people prefixing the name of a table with something like tbl? For example: create table tblCUSTOMERS ( ... ); Seems to me that you should probably know that CUSTOMERS is a table, or is it just me? Looking forward to your input. Mike. On Thursday 04 August 2011 6:43:55 am David Lerer wrote: I agree. I use the same column name in all tables where it has the same function - but I consistently add a suffix or prefix. And yes, it is the old fashion way David. -Original Message- From: h...@tbbs.net [mailto:h...@tbbs.net] Sent: Thursday, August 04, 2011 8:26 AM To: r...@grib.nl Cc: mysql@lists.mysql.com Subject: Re: Too many aliases 2011/08/03 12:46 +0200, Rik Wasmus But the main thing is it helps to distinguish tables in joins having the same table more then once (and of course results from subqueries etc.): SELECT first.* FROM tablename first LEFT JOIN tablename second ONfirst.some_id = second.some_id AND first.id != second.id WHERE second.id IS NULL Well, yes, here it is needful. But it seems to me from most of the examples that people here post, that they have the idea that it is the style always to use one-letter aliases, whether it is helpful or not. Now I do not do this, but I often see examples where a field for one purpose has in one table one name, and in another table another, slightly different, name, and then, too, I see alias used, although, in this case, no table name at all is needed. (I like to use the same field name in all tables where it has the same function.) -- Take care and have fun, Mike Diehl. -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org
Re: Too many aliases
http://en.wikipedia.org/wiki/Hungarian_notation On Thu, Aug 4, 2011 at 9:41 AM, Mike Diehl mdi...@diehlnet.com wrote: Well, while we're on the subject of SQL style, can anyone tell me why I'm always seeing people prefixing the name of a table with something like tbl? For example: create table tblCUSTOMERS ( ... ); Seems to me that you should probably know that CUSTOMERS is a table, or is it just me? Looking forward to your input. Mike. On Thursday 04 August 2011 6:43:55 am David Lerer wrote: I agree. I use the same column name in all tables where it has the same function - but I consistently add a suffix or prefix. And yes, it is the old fashion way David. -Original Message- From: h...@tbbs.net [mailto:h...@tbbs.net] Sent: Thursday, August 04, 2011 8:26 AM To: r...@grib.nl Cc: mysql@lists.mysql.com Subject: Re: Too many aliases 2011/08/03 12:46 +0200, Rik Wasmus But the main thing is it helps to distinguish tables in joins having the same table more then once (and of course results from subqueries etc.): SELECT first.* FROM tablename first LEFT JOIN tablename second ONfirst.some_id = second.some_id AND first.id != second.id WHERE second.id IS NULL Well, yes, here it is needful. But it seems to me from most of the examples that people here post, that they have the idea that it is the style always to use one-letter aliases, whether it is helpful or not. Now I do not do this, but I often see examples where a field for one purpose has in one table one name, and in another table another, slightly different, name, and then, too, I see alias used, although, in this case, no table name at all is needed. (I like to use the same field name in all tables where it has the same function.) -- Take care and have fun, Mike Diehl. -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/mysql?unsub=joh...@pixelated.net -- - Johnny Withers 601.209.4985 joh...@pixelated.net
Re: Too many aliases
2011/08/02 12:11 +0530, Adarsh Sharma select p.* from table A p, B q where p.id=q.id or select p.* from table B q , A p where q.id=p.id Why do people constantly change table names for queries, although, as here, it gain them nothing? It often makes for less clarity (for which table is this an alias???). Depens on your table names. I rather like being able to give a short description rather then long table names if someone decided that as a tablename. I doubt your example with already short tablenames is one from real life, but if you saw someone doing it would indeed be a waste of time. But the main thing is it helps to distinguish tables in joins having the same table more then once (and of course results from subqueries etc.): SELECT first.* FROM tablename first LEFT JOIN tablename second ONfirst.some_id = second.some_id AND first.id != second.id WHERE second.id IS NULL -- Rik Wasmus -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org
RE: Too many aliases
I rarely use aliases (unless rarely required in self-join queries). When I have that option, I create unique columns by prefixing every table (and its objects) with a number. Something like: Create table T1234_Employee (C1234_Employee_id number(5), C1234_employee_status char(1)...) Index X1234_Employee_Id on Etc. Yes, the column names may be longer this way, but easy to refer to and easy to communicate (by specifying a table number). I wonder what others think about it. David. -Original Message- From: Rik Wasmus [mailto:r...@grib.nl] Sent: Wednesday, August 03, 2011 6:47 AM To: mysql@lists.mysql.com Subject: Re: Too many aliases 2011/08/02 12:11 +0530, Adarsh Sharma select p.* from table A p, B q where p.id=q.id or select p.* from table B q , A p where q.id=p.id Why do people constantly change table names for queries, although, as here, it gain them nothing? It often makes for less clarity (for which table is this an alias???). Depens on your table names. I rather like being able to give a short description rather then long table names if someone decided that as a tablename. I doubt your example with already short tablenames is one from real life, but if you saw someone doing it would indeed be a waste of time. But the main thing is it helps to distinguish tables in joins having the same table more then once (and of course results from subqueries etc.): SELECT first.* FROM tablename first LEFT JOIN tablename second ONfirst.some_id = second.some_id AND first.id != second.id WHERE second.id IS NULL -- Rik Wasmus -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/mysql?unsub=dle...@us.univision.com -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org
RE: Too many aliases
On Aug 3, 2011 9:24 AM, David Lerer dle...@us.univision.com wrote: I rarely use aliases (unless rarely required in self-join queries). When I have that option, I create unique columns by prefixing every table (and its objects) with a number. Something like: Create table T1234_Employee (C1234_Employee_id number(5), C1234_employee_status char(1)...) Index X1234_Employee_Id on Etc. Yes, the column names may be longer this way, but easy to refer to and easy to communicate (by specifying a table number). I wonder what others think about it. Looks COBOL-ish (IIRC what COBOL looks like) :) I much prefer shorter names but can agree that, if this leads to obscurity, use the namespace the engine provided you. I don't like typing if I don't have to but I *hate* saying, 'what the hell was I thinking'. I generally call index fields ix_*, foreign key columns *_fk, primary key columns *_pk, constraints table_field. That's about it.