Welcome to HostingForumz.com!
FAQFAQ   SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log in/Register/PasswordLog in/Register/Password

Any SQL experts here?

 
Goto page Previous  1, 2, 3, 4, 5, 6
   Web Hosting Problem Solving Community! (Home) -> Webmaster RSS
Related Topics:
SE ranking - any experts in here? - One of my sites is getting a low SE ranking, any _experts_ in here care to comment - or point me to a good forum? I run two gaming sites, they are both very similar, just for different but equally popular games. They are both

Are there any quark experts out there? - Hi All. I have been asked by a company to improve the method by which they update their website. at the moment, they use a manual method of data entry via an admin interface and upload images via FTP. They currently use Quark for..

Any experts on IE's controls around here? - I've somehow managed to swap the positions of the Quick Launch (the bit on the left of the Task bar) and the running programs (the bit in the middle of the Task bar, not the icons area). I've clicked this mouse till..

Any Video On Demand experts in here? - I wish to save a few streaming file the link of which, when you clickm on it, calls Windows Media Player to play it. I'm pretty sure, it's either an ASF or a WMV file. The problem is, when I right click on the link that calls WMP and choose to save, it.

Any Linux server experts about? - Any Linux server experts about? We have a problem with our server being a little I managed to get the following out of 5:17am up 118 days, 15:02, 1 user, load average: 141.56, 144.92, 144.34 But that's all, I can't even..
Author Message
jstucklex

External


Since: Jul 14, 2003
Posts: 1507



(Msg. 61) Posted: Thu Feb 07, 2008 8:00 am
Post subject: Re: Any SQL experts here? [Login to view extended thread Info.]
Archived from groups: alt>www>webmaster (more info?)

Andy Dingley wrote:
> On 6 Feb, 19:23, Jerry Stuckle <jstuck....DeleteThis@attglobal.net> wrote:
>
>>> Whatever. Whoever the guilty party is, mysql_insert_id() (callable
>>> from PHP) isn't an exact facade for LAST_INSERT_ID() (not callable
>>> from PHP)
>> You should check your facts better, Andy. SELECT LAST_INSERT_ID() works
>> fine in PHP.
>
> It works fine "from" PHP, but not "in" PHP. It's a SQL function, not
> something that's callable directly as a PHP statement. You need to
> pass it to a driver and have some SQL engine execute it, not call it
> directly.
>

Running out of arguments so you have to pick minor points in words, Andy?

>> And they are exactly the same. Just one is a little more
>> efficient than the other (no need to parse the SQL).
>
> They're not the same (this is rather my point), read their
> documentation. There are two differences in their interface. Interface
> facades that are "similar" rather than "equivalent" are always a good
> source of future bugs.
>

No, they are exactly the same. They return exactly the same thing.
Both are well documented. It's just two different ways to get to the
same end.

>
>> The simple answer is - use good coding practices.
>
> Part of good coding practice is to use or design tools that assist,
> not set traps for you. PHP _can_ be coded well (most of MediaWiki's
> innards), but more usually it's an insecure bag of nails (most
> amateurs' sites, or the innards of PhpBB).
>

Yep. And that's why I use PHP. But the language is not responsible for
poor coding habits.

But tools do not encourage good coding practices. In fact, in some
cases they discourage them. No coding tool I know of, for instance,
will prevent SQL injection attacks (from any language and with any
database). But those tools can give you a false sense of security.
OTOH, a good design can show those possibilities. And peer review makes
it even more reliable.

> Using GOTO isn't the bad thing (it's usually all you've got),
> choosing languages that force you to use it is.
>

In the last 25+ years, the only language I've used that "forces" me to
use it is assembler (both IBM and Intel platforms). And I don't think
outside of those I've ever used a goto in that time.

>
>
>>>> In fact,
>>>> if you want to use ANY database with ANY language, you have to compile
>>>> that support in.
>>> I have to compile in some support for an abstract DB. I shouldn't have
>>> to compile in different support for each instance of a server
>>> platform.
>> And how do you access Oracle, MS SQL and DB2 from your "abstract DB"
>> without the appropriate libraries? ODBC? So you need to compile in the
>> ODBC library code.
>
> ODBC (or JDBC, or whatever) is the abstract driver interface and I've
> already included support for it. I don't have to recompile my core
> just to switch the DB back-end platform!
>

Actually, if you use shared libraries or dll's properly, you don't have
to recompile your code, either. Just load the appropriate library.

> As I'm mostly coding in either Java or Python, the idea of
> "recompiling cores" just to add features strikes me as ridiculously
> obsolete anyway. Haven't these people heard of dynamic loading?
> <http://xkcd.com/353/>
>

Sure. See above. But dynamic loading also has its disadvantages - i.e.
they require more memory and Os calls to access the DLL.

>
>> That's true. But you still have to compile in the ODBC code. And not
>> only is it slower than native access to any of the databases, you are
>> also limited to the least common denominator across all databases. You
>> can't take advantage of the database-specific features.
>
> You missed out that "Java is slow because it uses a JVM" too.
>

Yes, it suffers from the same problem as SmallTalk. But that isn't the
subject here.

> You've posted so many red herrings this week you could open a
> fishmongers.
>

Running out of arguments, are you?

>
>> And BTW - have you looked at the cost of the MS SQL ODBC driver for
>> Linux? $1,500 just to access the database.
>
> Free, you just need to look harder at where you get them from.
>

Ah, but you want the REAL MS drivers. That way you know they work!

> Mind you, I used to do Java servlet work under IIS / W2K with MS SQL
> as a back-end. I was spending a _fortune_ on the Merant drivers (JDBC
> to SQL Server), because there was a gap in the market that no-one felt
> like filling for free. This can be a real problem and cost, I just
> don't think it is any more (now I'm using a freebie JTDS driver).
>

I though you only use MS drivers.

>
>> So you send the SQL to another system, parse it to see what needs to be
>> done, perform the operation, then send the data back across the link.
>> Seems to be an awful lot of overhead.
>>
>> My programs call the database directly across the link. That's one less
>> thing which needs to be done, and one less thing which can go wrong.
>
> "one less thing which can go wrong", such as duplicating SQL language
> parsing in your client platform?
>

And who is doing that? When using remote databases, the parsing is done
on the server.

> For someone with "years of database experience", you still seem a bit
> flakey on the core concepts of a client-server DB platform.
>
>

Nope. I just don't agree with your "analysis". I showed this thread to
a couple of DBA friends of mine (they have some 500tb+ databases). They
just groaned because they've had programmers who thought like you and
had to be retrained.

>
>>>>> What's _wrong_ with using LAST_INSERT_ID() insert some neatly packaged
>>>>> SQL module, then throwing the value away afterwards because it really
>>>>> isn't necessary to know it afterwards? That's good design, according
>>>>> to "modular programming" concepts that have been regarded as a basic
>>>>> starting point for good design for 30-some years now.
>>>> Why even use it if you're just going to throw it away?
>>> Because the DB has already stored it. However the application code no
>>> longer needs the value. In most cases, and where primary keys used for
>>> foreign keys are anonymous sequences rather than visible SSNs etc,
>>> then this is just as it should be. Locate the records through their
>>> descriptive properties, leave the internal IDs inside the DB code as
>>> much as possible. If you absolutely must, retrieve a "reference"
>>> later and leave it alone as an opaque reference the app code doesn't
>>> fiddle with.
>> True - but you need to fetch the insert id to add rows to the related
>> tables.
>
> Assuming we only ever add rows to the foreign-keyed table once (for
> this key value), why should I ever need to "fetch" anything? In
> particular, why should I need to fetch it across a network linik
> between servers, back to the client app?
>

Since you only do it once, there's very little overhead to accessing the
key. But your primary key is compared millions of times (or, in the
case of a busy database, potentially billions of times every day).

> This key value stays inside the SQL, stays inside the SQL server and
> ought to stay inside a transaction too. If you can do it right (for a
> single append statement to both tables at once) then you don't even
> need to handle this value explicitly as a variable in your SQL source
> code.
>

You can. But what if you have to add 20 rows to 5 different tables?
Let's see you do all of that in one statement - and have that statement
understandable.

I would say that when I'm adding to relational tables, I'm updating at
least three tables over 1/2 the time. Often more.

And updating multiple tables in one SQL statement makes it more
difficult to analyze and correct errors should one of the updates fail.

>
>> OO is a completely new
>> concept. And MVC may have been talked about, but was seldom used 30
>> years ago.
>
> Maybe "OO is completely new" to you Jerry, but both OO and MVC have
> been around since the mid-70s. They weren't commonly seen, but they
> sure were talked about a lot (just read Byte from the early '80s).
> I've been using MVC myself in mainstream M$oft code since Windows 3.0,
> 18 years ago, not from any radical forward-looking, but just because
> that's how the standard tools worked.
>
>

You said 30 years ago, which was in the late 70's, and OO was new then.
There were no OO languages. But I'll bet you can't even name the
first OO language without looking it up on the internet (hint - it was
NOT java).

MVC wasn't even though about back then.

And if you think Byte was the latest in technology, then I understand
where you got many of your misunderstandings.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex.DeleteThis@attglobal.net
==================

 >> Stay informed about: Any SQL experts here? 
Back to top
Login to vote
jstucklex

External


Since: Jul 14, 2003
Posts: 1507



(Msg. 62) Posted: Thu Feb 07, 2008 8:19 am
Post subject: Re: Any SQL experts here? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Andy Dingley wrote:
> On 6 Feb, 18:25, Jerry Stuckle <jstuck....RemoveThis@attglobal.net> wrote:
>
>> There is no way
>> members of a bounded set can be *guaranteed* unique.
>
> Of course it can! As soon as you start applying bounds you make it
> very easy to guarantee uniqueness (NB this is a bound on the overall
> domain, not just the cardinality of its members). There's a limit in
> how many of them you can have, but that's big enough for us to live
> with.
>

OK, here's your bound set:

{1, 2, 3}

I need 4 unique values.

>
>> Eventually you will run out of numbers. Then what do you do?
>
> Invent something better. This, along with the Moon running to a
> standstill and the heat death of the universe, is a very real problem,
> it's just so far off that it's not a problem I have to worry about.
>

It can be a real problem with GUID's, also. All you need is one
collision to corrupt a database.

>
>>> Can't afford 128 bits? You must be paying your developers awfully
>>> cheaply if that's a remotely good trade-off.
>> Let's see.. 128 bits is 16 bytes. An integer is 4 bytes.
>
>> Every computer I've ever seen uses bytes.
>
> Get yourself some bigger integers. If you're juggling TB data, a
> processor word should 64 bit by now, not 8
>

This has nothing to do with words, Even 64 bit processors use bytes.
It's just that they can operate on 8 bytes at at time.

> Secondly, this is a linear scaling factor (and arguably not a big
> one). I don't sweat the linear stuff when scaling, I'm worrying about
> the exponentials first.
>

Rather, you should be looking at the performance bottlenecks. Linear
scaling may actually be worse than exponential, if it's used more often.

>
>> Let's look at a table with 10M rows. You will have 160M bytes just for
>> your key field. I will have 40M bytes. At 100M rows, that increases to
>> 1.6B bytes for you and 400M bytes for me. That 1.2B bytes can be
>> important, especially if you are restricted by the OS to a 4GB table.
>
> The odd gig here and there just isn't a problem today. I admit I've
> never tried to put 100M rows through MySQL, or M$oft Access for that
> matter.
>

Ah, but it is very important. And since you just admitted you've never
worked with big databases, you really don't know, do you?

Not only does it require more memory to handle the tables and indexes,
it requires more reads just to get to the data. That's a potential
performance problem.

> For that matter, big databases don't even count "rows". If you mean a
> _BIG_ database these days, you're talking about OLAP, hypercubes and
> datawarehousing, not old-tech RDBMS and SQL.
>

Yes, they do. Every dba on big systems looks at the number of rows in
the tables. It's one of the considerations that they use when designing
large systems.

>> In short, your method of using GUID's is not very scalable.
>
> First, it's not my method. It's a good method, so I'd like to claim
> credit for it, but I can't. I just learned it by reading Kimball.
>

It's very poor method.

> Secondly, tell _him_ about it. One of the major recognisable names
> around in DB theory and architecture, his word does tend to carry more
> weight than yours or mine.
>

Maybe recognizable to you. The two dba's I mentioned in the other
thread (who are very well known in their circles and attend major
international conferences every year) never heard of him.

>
>> No, I haven't benchmarked GUIDs themselves.
>
> So you're talking straight out of your backside.
>

Nope. But I have benchmarked non-integer vs. integer keys.

> I _have_ benchmarked GUID performance for foreign keys, I've done it
> for GB-sized DBs, I've done it in blue-chip research labs, I've
> published the results, I've been invited to speak internationally on
> those results, and I've been awarded patents on work derived from
> those results. Improvements to efficient architectures for RDF triple
> stores, if you care.
>

OK, try this one. Set up a table with 100M rows. Have a second table,
also with 100M rows. Use GUID's as keys.

Now create a many-to-many link table between the two with say 5 random
links between the two tables.


Now create a loop which pulls one value at random (not by the key) out
of the first table and all of the related rows in the second table (via
the link table). Repeat 100K times. How long did it take?

Repeat, only using integer keys.

In both cases, you are allowed to tune the performance of the database
to give best results.

>> I could care less about your patents, Andy.
>
>
>
>
>> I've worked on some very large databases over the years - even
>> mainframes with > 100M entries. The size of the key used to
>> cross-reference tables is very critical - as anyone with experience in
>> large databases will tell you.
>
> Of course it is. 128 bits is manageable on today's hardware. Stop
> thinking we're still loading things off cards, like you used to for
> your years of experience.
>

You must be really running out of arguments, Andy. More degrading
comments instead of facts.
>
>> A lot of people come to me for advice,
>
> Business is so good that Maryland wound you up for non-filing? That
> must be a business that's _so_ busy you don't even get time to run it.
>

ROFLMAO! You think you know what you're talking about. But you're just
trolling again.

> Besides which, you lost a contract from a FTSE100 for DB2 developer
> training just recently because of your attitude. I know, I was the one
> resourcing it.
>

Nope. I wouldn't have accepted you anyway. Do you have at least 500
developers needing to be trained on DB2? Those are the customers I work
with.

But then, had you called me, I would have turned you down anyway.

>
>> And ANSI disagrees with you. As do IBM, Microsoft, and other major
>> RDBMS players. Otherwise they could have implemented an automatic GUID
>> creation in their database. But they didn't.
>
> Check again, they have. What's (MS') NEWID()? Chopped liver?
>

OK, I wasn't aware NEWID() was the GUID. But then MS never was very
good at performance.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex.RemoveThis@attglobal.net
==================

 >> Stay informed about: Any SQL experts here? 
Back to top
Login to vote
SpaceGirl

External


Since: Nov 13, 2005
Posts: 119



(Msg. 63) Posted: Thu Feb 07, 2008 8:49 am
Post subject: Re: Any SQL experts here? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Feb 7, 3:55 pm, Andy Dingley <ding... RemoveThis @codesmiths.com> wrote:
> On 7 Feb, 15:39, SpaceGirl <nothespacegirls... RemoveThis @subhuman.net> wrote:
>
> > I'm more interested in experimentation, and I'm happy to learn from my
> > mistakes if it blows up in my face.
>
> Wrongly-designed databases don't usually "blow up", they smoulder
> slowly. Then at some future point, they burn through your hardware
> budget and bottom line. The mistakes often don't become obvious from
> the outside until it has become _very_ expensive to fix them.
>
> I don't think I've ever personally seen a software fault as expensive
> as faults of database design. Their design becomes so embedded in a
> business, so critical, yet so difficult to fix, that no other piece of
> software has the capability to cause such expensive havoc.

Yep, I'm approaching this project with some caution - usually I
wouldn't even bother designing a schema on paper first, but this time
I did. I could post a PDF if anyone is interested Smile This project is
a user contributed magazine (kinda, it's all very web 2.0 but I think
we have a new spin Very Happy), kinda community based, but not expecting a
vast userbase. Also built into our plan is the fact this first version
is just a prototype, so it's not critical if it goes wrong, even at a
low level databasey place. So long as it works and can demonstrate it
works, then I'll be happy.
 >> Stay informed about: Any SQL experts here? 
Back to top
Login to vote
John Bokma

External


Since: Apr 27, 2005
Posts: 593



(Msg. 64) Posted: Thu Feb 07, 2008 6:05 pm
Post subject: Re: Any SQL experts here? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Jerry Stuckle <jstucklex.RemoveThis@attglobal.net> wrote:

> Dylan Parry wrote:
>> Jerry Stuckle wrote:
>>> Or come the end of daylight savings time when the entire system goes
>>> back one hour?
>>
>> The solution to that is UTC, which doesn't change with the seasons.
>>
>
> If your server is set to run UTC.

You can set your connection's timezone (assuming MySQL):

SET time_zone=YourTimeZoneHere

I admit, working with Time Zones in MySQL is a PAIN IN THE ASS, but it's
possible Smile

--
John Bokma http://johnbokma.com/
 >> Stay informed about: Any SQL experts here? 
Back to top
Login to vote
John Bokma

External


Since: Apr 27, 2005
Posts: 593



(Msg. 65) Posted: Thu Feb 07, 2008 6:05 pm
Post subject: Re: Any SQL experts here? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

mynameisnobodyodyssea.TakeThisOut@googlemail.com wrote:

> I should not have written time as a suggestion for
> unique values, I should have clarified that I meant
> as a suggestion something including time, like
> time plus a random string

Not safe, there is no guarantee that the random string + time is globally
unique. Use SELECT UUID() (see: http://en.wikipedia.org/wiki/UUID )

MS SQL has, IIRC a way to use timestamps which are guarantueed to be
unique. (Probably by using them as PK, or with a UNIQUE constraint, see
documentation).

--
John Bokma http://johnbokma.com/
 >> Stay informed about: Any SQL experts here? 
Back to top
Login to vote
John Bokma

External


Since: Apr 27, 2005
Posts: 593



(Msg. 66) Posted: Thu Feb 07, 2008 6:05 pm
Post subject: Re: Any SQL experts here? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Jerry Stuckle <jstucklex.TakeThisOut@attglobal.net> wrote:

> But tools do not encourage good coding practices. In fact, in some
> cases they discourage them. No coding tool I know of, for instance,
> will prevent SQL injection attacks (from any language and with any
> database).

In both Perl and Java you can prepare a statement with placeholders (?)
for years and years. You can't inject SQL into that. PHP has been an
exception to this for quite some time IIRC. (Hence all the magic strip
slash quoting garbage most people don't understand, and hence often
avoid).

> But those tools can give you a false sense of security.

IMNSHO placeholders don't. It's clear what they do, they safe you from
quoting garbage and 1001 checks if the data is not a SQL injection.

>> Using GOTO isn't the bad thing (it's usually all you've got),
>> choosing languages that force you to use it is.
>
> In the last 25+ years, the only language I've used that "forces" me to
> use it is assembler (both IBM and Intel platforms). And I don't think
> outside of those I've ever used a goto in that time.

Most people don't see that constructs like "next, redo, break, last" are
just gotos with a different name. It's not the goto that makes bad code,
it's the programmer.

>>> That's true. But you still have to compile in the ODBC code. And
>>> not only is it slower than native access to any of the databases,
>>> you are also limited to the least common denominator across all
>>> databases. You can't take advantage of the database-specific
>>> features.

Not true. A lot of DB specific features can be used via ordinary SQL. Of
course that makes switching drivers harder, but that's not always an
issue.

[rest snipped]


--
John Bokma http://johnbokma.com/
 >> Stay informed about: Any SQL experts here? 
Back to top
Login to vote
jstucklex

External


Since: Jul 14, 2003
Posts: 1507



(Msg. 67) Posted: Thu Feb 07, 2008 6:05 pm
Post subject: Re: Any SQL experts here? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

John Bokma wrote:
> Jerry Stuckle <jstucklex.TakeThisOut@attglobal.net> wrote:
>
>> Dylan Parry wrote:
>>> Jerry Stuckle wrote:
>>>> Or come the end of daylight savings time when the entire system goes
>>>> back one hour?
>>> The solution to that is UTC, which doesn't change with the seasons.
>>>
>> If your server is set to run UTC.
>
> You can set your connection's timezone (assuming MySQL):
>
> SET time_zone=YourTimeZoneHere
>
> I admit, working with Time Zones in MySQL is a PAIN IN THE ASS, but it's
> possible Smile
>

Yes, that works with MySQL, but what about other programs? Not all of
them work off of UTC and the time zone environment. They just pick up
the server time.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex.TakeThisOut@attglobal.net
==================
 >> Stay informed about: Any SQL experts here? 
Back to top
Login to vote
jstucklex

External


Since: Jul 14, 2003
Posts: 1507



(Msg. 68) Posted: Thu Feb 07, 2008 6:05 pm
Post subject: Re: Any SQL experts here? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

John Bokma wrote:
> Jerry Stuckle <jstucklex.TakeThisOut@attglobal.net> wrote:
>
>> But tools do not encourage good coding practices. In fact, in some
>> cases they discourage them. No coding tool I know of, for instance,
>> will prevent SQL injection attacks (from any language and with any
>> database).
>
> In both Perl and Java you can prepare a statement with placeholders (?)
> for years and years. You can't inject SQL into that. PHP has been an
> exception to this for quite some time IIRC. (Hence all the magic strip
> slash quoting garbage most people don't understand, and hence often
> avoid).
>

That's been more of a MySQL problem than a PHP one, John. Earlier
versions didn't have prepared statements. Once MySQL supported them, PHP
got on board with a new interface to support them.

But strip slash quoting never was a good idea - MySQL had a function
just for that purpose (mysql_escape_string, later
mysql_real_escape_string). I think it was more people writing
"tutorials" who really didn't understand what they were doing.

>> But those tools can give you a false sense of security.
>
> IMNSHO placeholders don't. It's clear what they do, they safe you from
> quoting garbage and 1001 checks if the data is not a SQL injection.
>

But placeholders aren't a "tool".

>>> Using GOTO isn't the bad thing (it's usually all you've got),
>>> choosing languages that force you to use it is.
>> In the last 25+ years, the only language I've used that "forces" me to
>> use it is assembler (both IBM and Intel platforms). And I don't think
>> outside of those I've ever used a goto in that time.
>
> Most people don't see that constructs like "next, redo, break, last" are
> just gotos with a different name. It's not the goto that makes bad code,
> it's the programmer.
>

No, next, et. al. are part of structured programming and have very
specific purposes. goto, OTOH, can really screw up your code. Even
Kernighan and Ritchie indicated they didn't *want* to put goto in the C
language, but felt they had to because people were so used to using it.

But for instance - with a goto, you can jump into the middle of a block
of code, bypassing variable initialization, etc. You can't do that with
the other statements.

>>>> That's true. But you still have to compile in the ODBC code. And
>>>> not only is it slower than native access to any of the databases,
>>>> you are also limited to the least common denominator across all
>>>> databases. You can't take advantage of the database-specific
>>>> features.
>
> Not true. A lot of DB specific features can be used via ordinary SQL. Of
> course that makes switching drivers harder, but that's not always an
> issue.
>

Yes - "A lot of DB specific features". But you're still limited by the
interface. Not all features are available.

> [rest snipped]
>
>


--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex.TakeThisOut@attglobal.net
==================
 >> Stay informed about: Any SQL experts here? 
Back to top
Login to vote
John Bokma

External


Since: Apr 27, 2005
Posts: 593



(Msg. 69) Posted: Thu Feb 07, 2008 9:04 pm
Post subject: Re: Any SQL experts here? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Jerry Stuckle <jstucklex RemoveThis @attglobal.net> wrote:

> John Bokma wrote:

[..]

>> You can set your connection's timezone (assuming MySQL):
>>
>> SET time_zone=YourTimeZoneHere
>>
>> I admit, working with Time Zones in MySQL is a PAIN IN THE ASS, but
>> it's possible Smile
>>
>
> Yes, that works with MySQL, but what about other programs?

What other programs? (in which language are those programs written?)

--
John Bokma http://johnbokma.com/
 >> Stay informed about: Any SQL experts here? 
Back to top
Login to vote
jstucklex

External


Since: Jul 14, 2003
Posts: 1507



(Msg. 70) Posted: Thu Feb 07, 2008 9:04 pm
Post subject: Re: Any SQL experts here? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

John Bokma wrote:
> Jerry Stuckle <jstucklex.RemoveThis@attglobal.net> wrote:
>
>> John Bokma wrote:
>
> [..]
>
>>> You can set your connection's timezone (assuming MySQL):
>>>
>>> SET time_zone=YourTimeZoneHere
>>>
>>> I admit, working with Time Zones in MySQL is a PAIN IN THE ASS, but
>>> it's possible Smile
>>>
>> Yes, that works with MySQL, but what about other programs?
>
> What other programs? (in which language are those programs written?)
>

Many commercial programs out there. C, C++, Java, you name it. A
significant number work off the local clock only.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex.RemoveThis@attglobal.net
==================
 >> Stay informed about: Any SQL experts here? 
Back to top
Login to vote
Jamie

External


Since: Feb 08, 2008
Posts: 36



(Msg. 71) Posted: Fri Feb 08, 2008 3:05 am
Post subject: Re: Any SQL experts here? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

In <6b7a5cdf-bb8a-4dbc-ab6a-5495e61af5d7.DeleteThis@h11g2000prf.googlegroups.com>,
SpaceGirl <nothespacegirlspam.DeleteThis@subhuman.net> mentions:
>Quick SQL question:
>
>Table A contains articles
>Table B contains images that belong to articles
>
>Inserting a new record (article) into table A, which has an
>incrementing primary key. Several entries also need to be made in
>table B, containing the images that belong to the article in table A.
>How do I get the key value from A and put it in B at the same time as
>inserting A.

As everyone else pointed out, if you're stuck with mysql, you'd look for
insert_id() (different languages and API's provide different access to it)

If you're lucky enough to be able to use postgresql (my favorite) you could
use a sequence and thus, gain access to the ID before inserting it.

All these years and as far as I know, there still isn't a good, portable way
to generate these ID's. (time was... we used to use counter files!)

Go with postgresql if possible, it's got all kinds of neat stuff to ensure
referential integrity. Light-years ahead of mysql, except where connection
speeds are concerned. (yea... I use mysql, but mostly because that is what
everyone else seems to use)


Jamie
--
http://www.geniegate.com Custom web programming
Perl * Java * UNIX User Management Solutions
 >> Stay informed about: Any SQL experts here? 
Back to top
Login to vote
John Bokma

External


Since: Apr 27, 2005
Posts: 593



(Msg. 72) Posted: Fri Feb 08, 2008 3:05 am
Post subject: Re: Any SQL experts here? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Jerry Stuckle <jstucklex.DeleteThis@attglobal.net> wrote:

> John Bokma wrote:
>> Jerry Stuckle <jstucklex.DeleteThis@attglobal.net> wrote:
>>
>>> John Bokma wrote:
>>
>> [..]
>>
>>>> You can set your connection's timezone (assuming MySQL):
>>>>
>>>> SET time_zone=YourTimeZoneHere
>>>>
>>>> I admit, working with Time Zones in MySQL is a PAIN IN THE ASS, but
>>>> it's possible Smile
>>>>
>>> Yes, that works with MySQL, but what about other programs?
>>
>> What other programs? (in which language are those programs written?)
>>
>
> Many commercial programs out there. C, C++, Java, you name it. A
> significant number work off the local clock only.

OK, I name Perl:

time
The current time is: 23:35:48.87
Enter the new time:

perl -e "print scalar gmtime"
Fri Feb 8 05:35:51 2008

perl -e "print scalar localtime"
Thu Feb 7 23:35:57 2008

AFAIK, C, C++, Java, and probably you name it as well are able to get the
local time and the time in GMT (unless you configured your system wrong)

--
John Bokma http://johnbokma.com/
 >> Stay informed about: Any SQL experts here? 
Back to top
Login to vote
dingbat

External


Since: Jan 01, 2004
Posts: 187



(Msg. 73) Posted: Fri Feb 08, 2008 3:18 am
Post subject: Re: Any SQL experts here? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On 7 Feb, 16:49, SpaceGirl <nothespacegirls....DeleteThis@subhuman.net> wrote:

> wouldn't even bother designing a schema on paper first, but this time
> I did.

Then there's the Agile approach, which sees the irreversibility of
decisions as being a bad thing, then tries to produce a method of
working that doesn't suffer from it.

<http://martinfowler.com/articles/evodb.html>
 >> Stay informed about: Any SQL experts here? 
Back to top
Login to vote
mynameisnobodyodyssea

External


Since: Nov 16, 2007
Posts: 32



(Msg. 74) Posted: Fri Feb 08, 2008 4:59 am
Post subject: Re: Any SQL experts here? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Feb 7, 9:25 pm, John Bokma wrote:
> mynameisnobodyodys.. wrote:
> > I should not have written time as a suggestion for
> > unique values, I should have clarified that I meant
> > as a suggestion something including time, like
> > time plus a random string
>
> Not safe, there is no guarantee that the random string + time is globally
> unique. Use SELECT UUID() (see:http://en.wikipedia.org/wiki/UUID)
>
> MS SQL has, IIRC a way to use timestamps which are guarantueed to be
> unique. (Probably by using them as PK, or with a UNIQUE constraint, see
> documentation).
>
> --
> John Bokma

Mr. Bokma,
I am sorry, but you quoted just a fragment of my posting.
I wrote time plus a random string, plus maybe something else,
plus check if there is failure warning for duplicate value
for primary key.
Just as a suggestion, anything unique would obviously do.

I admit that my suggestion becomes more and more complicated
as I try to clarify it, I apologize for that.

I suggested time included somehow in an id column
for the id column to have an id value (unique)
and also to include parse-able time, in case
the value of the time when data is added to the
table might be needed, so to economize a column
for time (sorry for the new added complications
about time).
 >> Stay informed about: Any SQL experts here? 
Back to top
Login to vote
SpaceGirl

External


Since: Nov 13, 2005
Posts: 119



(Msg. 75) Posted: Fri Feb 08, 2008 5:47 am
Post subject: Re: Any SQL experts here? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Feb 8, 12:48 pm, Mark Goodge <use... RemoveThis @listmail.good-stuff.co.uk>
wrote:
> On Fri, 08 Feb 2008 05:30:28 GMT, Jamie put finger to keyboard and
> typed:
>
>
>
> >Go with postgresql if possible, it's got all kinds of neat stuff to ensure
> >referential integrity. Light-years ahead of mysql, except where connection
> >speeds are concerned. (yea... I use mysql, but mostly because that is what
> >everyone else seems to use)
>
> PostgreSQL used to be really buggy, compared to MySQL. It isn't any
> more (and meanwhile, MySQL has caught up a lot on the areas it used to
> be weak on, which was mainly functionality), but in that past that was
> a very good reason for shared hosting providers to prefer MySQL as
> it's easier to support a reliable, if rather limited, dba than a more
> complete but less predictable one - especially where you're dealing
> with less than clueful customers who are rarely going to want the
> additional functionality offered by PostgreSQL anyway.
>
> If I was starting from scratch now, with no code to port from
> elsewhere, I'd be more inclined to recommend PostgreSQL. But MySQL has
> the momentum and, in this kind of situation, popularity generates
> popularity as it's so easy to find code examples for MySQL and so easy
> to find web hosts that provide it.
>
> Mark
> --http://www.MotorwayServices.info- read and share comments and opinons
> "I feel these four walls closing in"

I had an interesting chat with a web team person at the BBC last year.
Their stats and fun end databases are MySQL5. If the BBC web site,
which is one of the busiest in the world, can manage with MySQL, I'm
sure it'll be more than fine for most people Smile

I doubt they use MySQL behind the scenes though for the bulk of the
content.
 >> Stay informed about: Any SQL experts here? 
Back to top
Login to vote
Display posts from previous:   
   Web Hosting Problem Solving Community! (Home) -> Webmaster All times are: Pacific Time (US & Canada) (change)
Goto page Previous  1, 2, 3, 4, 5, 6
Page 5 of 6

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]