Pig Latin Data Model
The data model of Pig Latin is fully nested and it allows complex non-atomic datatypes such asmapandtuple. Given below is the diagrammatical representation of Pig Latin’s data model.
Atom
Any single value in Pig Latin, irrespective of their data, type is known as anAtom. It is stored as string and can be used as string and number. int, long, float, double, chararray, and bytearray are the atomic values of Pig. A piece of data or a simple atomic value is known as afield.
Example− ‘raja’ or ‘30’
Tuple
A record that is formed by an ordered set of fields is known as a tuple, the fields can be of any type. A tuple is similar to a row in a table of RDBMS.
Example− (Raja, 30)
Bag
A bag is an unordered set of tuples. In other words, a collection of tuples (non-unique) is known as a bag. Each tuple can have any number of fields (flexible schema). A bag is represented by ‘{}’. It is similar to a table in RDBMS, but unlike a table in RDBMS, it is not necessary that every tuple contain the same number of fields or that the fields in the same position (column) have the same type.
Example− {(Raja, 30), (Mohammad, 45)}
A bag can be a field in a relation; in that context, it is known asinner bag.
Example− {Raja, 30,{9848022338, [email protected],}}
Map
A map (or data map) is a set of key-value pairs. Thekeyneeds to be of type chararray and should be unique. Thevaluemight be of any type. It is represented by ‘[]’
Example− [name#Raja, age#30]
Relation
A relation is a bag of tuples. The relations in Pig Latin are unordered (there is no guarantee that tuples are processed in any particular order).