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::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::Column object(s)
  • columns_to => Alzabo::Create::Column object(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 => $boolean
  • to_is_dependent => $boolean
  • comment => $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