Objects in database (Part 2)
Continue on objects in database:
- Constraint is rule set in table's columns, where data to be modified must follow. Example of constraint including:
- Primary Key, where the column(s) is the identifier of records in the table, must not be null (in Oracle, where there is relational database which allow primary key to be null) and must be unique.
- Unique, where data in this column must be unique or no duplicate, but can be null.
- Not null, where this column must not be null (null and empty or zero is not the same).
- Foreign Key, where data in this column must exist in another table's Primary key.
- Check, normally is the user defined constraint, for example this column can only have integer more than 0.
- Index is table reference which can make the search of record faster. Index is created based on column(s), and create a primary key will always generate an index based on the key.
- Function is a short hand of PL/SQL which can return a value. It can either be used in PL/SQL or inside a SQL statement.
- Procedure is also short hand of PL/SQL, which do not return any value. It cannot be used in SQL statement.
- Package is collection of functions and procedures. It has 2 parts:
- Package specification, where defined which function or procedure can be used by user, or open to public. The body of function and procedure will not be coded in here.
- Package body, where all the all the body of function and procedure is coded.
- Trigger is event handler of table. For example, we can create a trigger to do something when data is inserted, updated or deleted in a table.
- Sequence is code generator for records, and it can only generate integer.

0 comments:
Post a Comment