4 Replies Latest reply: Mar 5, 2007 5:34 PM by Newsgroup_User RSS

    Question for David Powers re file 'quotations.sql'

    Community Member
      It would appear from the first few lines of this file (shown below) that it
      first checks if a table "quotations" already exists, and if so deletes it. Then
      it creates a new version, and populates it with the following data.

      Is this correct?

      Clancy
      ...................................
      -- Table structure for table `quotations`
      --

      DROP TABLE IF EXISTS `quotations`;
      CREATE TABLE `quotations` (
      `quote_id` int(10) unsigned NOT NULL auto_increment,
      `quotation` varchar(255) NOT NULL default '',
      `first_name` varchar(30) NOT NULL default '',
      `family_name` varchar(30) NOT NULL default '',
      PRIMARY KEY (`quote_id`)
      ) ENGINE=MyISAM DEFAULT CHARSET=latin1;

      --
      -- Dumping data for table `quotations`
      --

      INSERT INTO `quotations` VALUES (1, 'My disability is ......'




      Clancy
        • 1. Re: Question for David Powers re file 'quotations.sql'
          Community Member
          "Clancy" <clancy@cybec.com.au> wrote in message
          news:2tdnu2pm3u0fnj9vnanb4sik7plroe6a62@4ax.com...
          > It would appear from the first few lines of this file (shown below) that
          > it
          > first checks if a table "quotations" already exists, and if so deletes it.
          > Then
          > it creates a new version, and populates it with the following data.
          >
          > Is this correct?

          Not David, but that's how I read that code, yes.


          • 2. Re: Question for David Powers re file 'quotations.sql'
            Community Member
            Clancy wrote:
            > It would appear from the first few lines of this file (shown below) that it
            > first checks if a table "quotations" already exists, and if so deletes it. Then
            > it creates a new version, and populates it with the following data.
            >
            > Is this correct?

            Yes. The purpose is to ensure that everyone starts with an identical,
            correctly structured database table.

            --
            David Powers, Adobe Community Expert
            Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
            Author, "PHP Solutions" (friends of ED)
            http://foundationphp.com/
            • 3. Re: Question for David Powers re file 'quotations.sql'
              Community Member
              David Powers <david@example.com> wrote:

              >Clancy wrote:
              >> It would appear from the first few lines of this file (shown below) that it
              >> first checks if a table "quotations" already exists, and if so deletes it. Then
              >> it creates a new version, and populates it with the following data.
              >>
              >> Is this correct?
              >
              >Yes. The purpose is to ensure that everyone starts with an identical,
              >correctly structured database table.

              I thought so. As the sql file redefines the table, is it necessary to define
              the table at all before running the file?

              I have been thinking about how to set up a database for my photo album, and
              wondering how to order it. If I have a text file, like 'quotations.sql', it
              looks as if the easiest way to change the order of the photos is to swap the
              lines in the text file, and then reload the whole database. The text file is
              quite small, so this should not involve excessive overheads.

              It also occurred to me that if this is all I want to use the database for I
              could probably dispense with it entirely by using php to scan the text file
              directly.

              Clancy
              • 4. Re: Question for David Powers re file 'quotations.sql'
                Community Member
                Clancy wrote:
                > I thought so. As the sql file redefines the table, is it necessary to define
                > the table at all before running the file?

                The purpose of the preceding section is to teach you how to define a
                table. If all you're interested in is copying my table structure, feel
                free to do so. However, I believe in the principle of teaching a man to
                fish, rather than giving a man a fish.

                > I have been thinking about how to set up a database for my photo album, and
                > wondering how to order it. If I have a text file, like 'quotations.sql', it
                > looks as if the easiest way to change the order of the photos is to swap the
                > lines in the text file, and then reload the whole database.

                If that's your conclusion, then I'm afraid that you have failed to
                understand the fundamental principles of how a database works. The order
                in which records are entered is totally irrelevant. You use SQL to
                display them in whichever order you require.

                --
                David Powers, Adobe Community Expert
                Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
                Author, "PHP Solutions" (friends of ED)
                http://foundationphp.com/