This is a beginner database question, go to the next library and get an introduction to RDBMS design/SQL book.

You are describing a Junction table.

$ echo ' create table articles (id integer not null, parsed text, primary k +ey (id)); create table information (id integer not null, something text, pri +mary key (id)); create table articles_information (articles_id integer not null, i +nformation_id integer not null, primary key (articles_id, information +_id), foreign key (articles_id) references articles (id), foreign key + (information_id) references information (id)); ' | sqlite3 M15U.sqlite
This example is already complicated enough that you should not bother with raw SQL in DBI, but use a higher-level ORM. DBIx::Class sample code:
use DBIx::Class::Schema::Loader qw(); DBIx::Class::Schema::Loader->naming('preserve'); my $schema = DBIx::Class::Schema::Loader->connect('DBI:SQLite:db=M15U. +sqlite'); my $foobar = $schema->resultset('Articles')->create({ id => 1, parsed +=> 'foo bar' }); $foobar->add_to_informations({ id => 1, something => 'quux' }); $foobar->add_to_informations({ id => 2, something => 'fnord' });
As long as the foreign keys are set up properly, the junction table is filled automatically:
$ echo .dump | sqlite3 M15U.sqlite | grep INSERT INSERT INTO "articles" VALUES(1,'foo bar'); INSERT INTO "information" VALUES(1,'quux'); INSERT INTO "information" VALUES(2,'fnord'); INSERT INTO "articles_information" VALUES(1,1); INSERT INTO "articles_information" VALUES(1,2);

In reply to Re: DBI relation between tables tutorial by daxim
in thread DBI relation between tables tutorial by M15U

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.