Alzabo...ignKey(3pm)
π Alzabo::Create::ForeignKey β the manual, but make it cute π
okay bestie, so this is a page from the User Contributed Perl Documentation set, and it's all about Alzabo::Create::ForeignKey. yes the header is literally Alzabo...ignKey(3pm) because terminals are dramatic like that, but you're here now, we're here together, let's go π«Ά
β¨ NAME β¨
Alzabo::Create::ForeignKey β foreign key objects, but for schema creation. like, the building phase. the construction era. π
πΈ SYNOPSIS πΈ
use Alzabo::Create::ForeignKey;
that's it. that's the whole synopsis. short and iconic, as she should be.
π¦ DESCRIPTION π¦
okay so a foreign key is an object, right? and it's defined by a bunch of properties. what it represents is a relationship from a column (or several columns) in one table, over to a column (or several columns) in another table. it's giving long distance relationship but make it relational algebra π
and that relationship is defined by two things:
- its cardinality β that's one to one, one to many, or many to one
- its dependencies β as in, is table X dependent on table Y, and vice versa?
π¨ many to many relationships are NOT allowed. nope. not happening. π
but!! (and this is the good part) you can indicate that kind of relationship when you use the Alzabo::Create::Schema->add_relation method method β and yes the original says "method method", we are keeping that, it's canon β and it will build the necessary intermediate linking table for you. it does the work. you just vibe. β¨
π INHERITS FROM π
Alzabo::ForeignKey
π note: all relevant documentation from the superclass has been merged into this document. so you don't have to go anywhere else, bestie, it's all right here.
π₯ METHODS π₯
new
the constructor! she takes the following parameters:
columns_from=>Alzabo::Create::Columnobject(s)columns_to=>Alzabo::Create::Columnobject(s)
so these two can be either a single column or a reference to an array of columns. and heads up β the number of columns in the two parameters must match. no mismatching, that's a red flag π©
cardinality=>[1, 1],[1, 'n'], or['n', 1]from_is_dependent=>$booleanto_is_dependent=>$booleancomment=>$comment
this one's an optional comment. little treat, if you want it. π
it returns a brand new Alzabo::Create::ForeignKey object. π«
Throws: Alzabo::Exception::Params
table_from
table_to
returns the relevant Alzabo::Create::Table object. one for from, one for to, you get it. π
columns_from
columns_to
returns the relevant Alzabo::Create::Column object(s) for that property β as an array. always an array. commitment. π
column_pairs
returns an array of array references. those references point at two-column arrays of Alzabo::Create::Column objects. and those two columns correspond to each other in the tables being linked together. they're paired up. matched. soulmates, lowkey. π
set_columns_from (Alzabo::Create::Column object(s))
sets the column(s) that the relation is from. can be either a single column object or a reference to an array of column objects. your call, bestie.
Throws: Alzabo::Exception::Params
set_columns_to (Alzabo::Create::Column object(s))
sets the column(s) that the relation is to. again β single column object, or a reference to an array of column objects.
Throws: Alzabo::Exception::Params
cardinality
returns a two element array with the two portions of the cardinality of the relationship. each portion is gonna be either '1' or 'n'. no in-between. binary. periodt.
from_is_dependent
to_is_dependent
returns a boolean value saying whether there's a dependency from one table to the other. yes/no. dependent or unbothered. π
is_one_to_one
is_one_to_many
is_many_to_one
returns a boolean value indicating what kind of relationship the object represents. it's a vibe check on the shape of the whole thing. β¨
set_cardinality (\@cardinality) see above for details
sets the cardinality of the foreign key. (the see above for details is doing so much heavy lifting there and we respect it π«Ά)
Throws: Alzabo::Exception::Params
set_from_is_dependent ($boolean)
indicates whether or not the first table in the foreign key is dependent on the other β meaning, whether the 'from' table is dependent on the 'to' table.
set_to_is_dependent ($boolean)
indicates whether or not the second table in the foreign key is dependent on the other β meaning, whether the 'to' table is dependent on the 'from' table.
id
returns a string that uniquely identifies the foreign key. one of a kind. main character energy. π
is_same_relationship_as ($fk)
you hand it a foreign key object, and it returns true if the two objects represent the same relationship. plot twist though: the two objects might be representing that same relationship from different tables' points of view. same ship, different deck. π’
comment
returns the comment associated with the foreign key object β if any. might be nothing. might be a whole essay. we don't know. π
set_comment ($comment)
sets the comment for the foreign key object. go off, write something cute. π
π AUTHOR π
Dave Rolsky, <autarch@urth.org> β thank you legend, we appreciate you π«Ά
and that's the whole page, bestie!! this was perl v5.34.0, dated 2022-06-14, from the User Contributed Perl Documentation collection, and honestly? iconic of it. now go build a schema. slay. πβ¨π
π¦ where this page comes from
- debian bookworm: libalzabo-perl 0.92-6 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libalzabo-perl 0.92-6 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libalzabo-perl 0.92-6 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libalzabo-perl 0.92-6 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libalzabo-perl 0.92-6 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms