Alzabo...ignKey(3pm)

πŸ“¦
version 0.92 Β· 2 versions
  • 0.92 Β· debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 0.92 Β· ubuntu jammy
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– Alzabo::ForeignKey β€” foreign key (relation) objects πŸ’–

okay bestie, welcome to the Alzabo::ForeignKey page from the User Contributed Perl Documentation section of the manual. it's giving ✨relationship lore✨ and honestly? we're obsessed. 🫢


🌸 SYNOPSIS 🌸

use Alzabo::ForeignKey;

foreach my $fk ($table->foreign_keys)
{
    print $fk->cardinality;
}

πŸ¦‹ DESCRIPTION πŸ¦‹

so. a foreign key is an object, right, and it's defined by a bunch of properties. what it actually represents is a relationship from a column (or several columns) in one table to a column (or several columns) in another table. it's the little red string connecting your tables, no cap. πŸŽ€

that relationship is defined by two things, bestie:

  • its cardinality β€” one to one, one to many, or many to one
  • its dependencies β€” like, whether table X is dependent on table Y, and vice versa
many to many relationships are NOT allowed. πŸ’€ however β€” and this is the slay part β€” you can indicate such a relationship when you're using the Alzabo::Create::Schema->add_relation method method (yes it says "method" twice, we love a typo with main character energy), and it will build the necessary intermediate linking table for you. iconic behaviour fr fr.

πŸ‘‘ METHODS πŸ‘‘

🌈 table_from / table_to

returns the relevant Alzabo::Table object. one for each end of the relationship. cute, simple, we love. πŸ’…

🌈 columns_from / columns_to

returns the relevant Alzabo::Column object(s) for the property as an array. yes, plural possible. she can hold multiple. ✨

🌈 column_pairs

returns an array of array references. each of those references points at a two-column array of Alzabo::Column objects, and those two columns correspond to each other in the tables being linked together. it's basically shipping them. πŸ₯°

🌈 cardinality

returns a two element array containing the two portions of the cardinality of the relationship. each portion will be either '1' or 'n'. that's it. that's the whole vibe check. ⭐

🌈 from_is_dependent / to_is_dependent

returns a boolean value indicating whether there's a dependency from one table to the other. true/false, dependent/not, the whole will-they-won't-they. πŸ™ˆ

🌈 is_one_to_one / is_one_to_many / is_many_to_one

returns a boolean value indicating what kind of relationship the object represents. three lil methods, three lil booleans, one big romance. πŸ’œ

🌈 is_same_relationship_as ($fk)

give it a foreign key object and it returns true if the two objects represent the same relationship. plot twist though bestie: the two objects may represent the same relationship from different tables' points of view. same ship, different deck. 🚒

🌈 id

returns a string uniquely identifying the foreign key. her government name. πŸŽ€

🌈 comment

returns the comment associated with the foreign key object, if any. if there's no comment, there's just... no comment. literally. 😭


πŸ’– AUTHOR πŸ’–

Dave Rolsky, <autarch@urth.org>


and that's the whole page bestie, you ate it up πŸ“ this lil manual page came to you via perl v5.34.0, dated 2022-06-14, straight out of the User Contributed Perl Documentation corner of the internet. periodt. πŸ’…βœ¨

πŸ“¦ where this page comes from