Differentiate between system generated constraint naming and user generated constraint nameing.

The difference between system generated constraint naming and user generated constraint naming are as follows: There are two level of constraint naming:
  • System generated system naming
  • user defined system naming
Also there are two levels of defining constraint naming. They are:
  • column level 
  • table level
  1. System generated, column level constraint 

    CREATE TABLE tbl_student_info (
    student_id_number primary key,
    FName varchar(25) NOT NULL,
    MName varchar(25),
    LName varchar(25) NOT NULL,
    Gender char(1) check (Gender IN('M','F','m','f')),
    DOB date NOT NULL,
    Email varchar (50) check (Email like '%@@'));
     example, 
          insert into tbl_student values(1,'Ram','bahadur','Karki','M','07/12/2012','ramg@gmal.com');
  1. User defined with column level and table level defining constraints  

    CREATE TABLE course_info(
    course_id number constraint  course_info_course_id_pk primary key,
    MdName varchar(25) constraint course_info_MdName_nn NOT NULL,
    MdCredit number constraint course_info_MdCredit_nn NOT NULL,
    SsPeriod char(6) constraint course_info_SsPeriod_nn NOT NULL,
    constraint course_info_MdCredit_c check (MdCredit>=3),
    constraint course_info_SsPeriod_c check(SsPeriod IN ('SPRING','AUTUMN'))
    );

    Advantage of using user defined constraint
    When the database structure is large and contains huge amount of data, it helps in performance tuning. 

0 comments:

Feel free to contact the admin for any suggestions and help.