3i Infotech Papers: Sample Questions 573 - 574 of 1245

Examrace Placement Series prepares you for the toughest placement exams to top companies.

Question number: 573

» Database » MySQL

Essay Question▾

Describe in Detail

Difference between “VARCHAR” and “VARCHAR2” datatypes.

Explanation

Difference between varchar and varchar2

Difference between varchar and varchar2

Varchar

Varchar2

Variable length character string

Variable length character string2

In Oracle, not recommended to be used currently. VARCHAR might be defined as a separate data type for variable-length character strings in the future

In Oracle, this datatype is used to store a variable length character string with a maximum of 4000 bytes.

VARCHAR can store up to 2000 bytes of characters

VARCHAR2 can store up to 4000 bytes of characters.

If we declare datatype as VARCHAR then it will occupy space for NULL values.

In case of VARCHAR2 datatype, it will not occupy any space.

If you enter value less than 10, it utilize total 10 spaces.

If you enter value, less than 10 then remaining space is not utilize.

Question number: 574

» Database » MySQL

Essay Question▾

Describe in Detail

Explain normalization with examples.

Explanation

  • Normalization is a database design technique, which organizes tables to reduce redundancy and dependency of data.

  • It divides larger tables to smaller tables and links them using relationships.

Example of Normalization:

Table showing the normalization table

Table showing the normalization table

Full Name

Physical address

Movies rented

salutation

category

Janat

First street plot No 4

Pirates of the Caribbean clash of the titans

Ms.

Action, Action

Rohit

3rd street 34

Forgetting Sarah Marshal Daddy’s Little Girls

Mr.

Romance, Romance

Rohit

5th Avenue

Clash of the Titans

Mr

Action

Database Normal Forms

1NF (First Normal Form) Rules

  • Each table cell should contain a single value.

  • Each record needs to be unique.

1NF Example:

Understanding the example of above Normalization table

Table showing the normalization table

Table showing the normalization table

Full Name

Physical Address

MOVIES RENTED

SALTUTATION

Janat

First Street Plot No 4

Pirates of the Caribbean

Ms.

Janat

First Street Plot No 4

Clash of the Titans

Ms.

Rohit

3rd Street 34

Forgetting Sarah Marshal

Mr.

Rohit

3rd Street 34

Daddy’s Little Girls

Mr.

Rohit

5th Avenue

Clash of the Titans

Mr.

2NF (Second Normal Form) Rules

  • It is clear that we cannot move forward to make our simple database in second Normalization form unless we partition the table above.

Table showing the normalization table

Table showing the normalization table

MEMBERSHIP ID

FULL NAMES

PHYSICAL ADDRESS

SALTUTATION

1

Janat

First street Plot No 4

Ms.

2

Rohit

3rd street 34

Mr.

3

Rohit

5th Avenue

Mr.

Table showing the normalization table

Table showing the normalization table

MEMBERSHIP ID

MOVIES RENTED

1

Pirates of the Caribbean

1

Clash of the Titans

2

Forgetting sarah Marshal

2

Daddy’s Little Girls

3

Clash of the Titans

  • We have divided our 1NF table into two tables’ viz. Table 1 and Table2.

  • Table 1 contains member information. Table 2 contains information on movies rented.

  • We have introduced a new column called Membership_id, which is the primary key for table 1. Records can be uniquely identified in Table 1 using membership id

    3NF (Third Normal From) Rules

  • To move our 2NF table into 3NF, we again need to again divide our table.

Example

Table showing the normalization table

Table showing the normalization table

MEMBERSHIP ID

FULL NAME

PHYSICAL ADDRESS

SALUTATION ID

1

Janat

First street plot No 4

2

2

Rohit

3rd street 34

1

3

Rohit

5th Avenue

1

Table showing the normalization table

Table showing the normalization table

MEMBERSHIP ID

MOVIES RENTED

1

Pirates of the Caribbean

1

Clash of the Titans

2

Forgetting Sarah Marshal

2

Daddy’s Little Girls

3

Clash of the Titans

Table showing the normalization table

Table showing the normalization table

SALUTATION ID

SALUTATION

1

Mr.

2

Ms.

3

Mrs.

4

Dr.

  • We have again divided our tables and created a new table, which stores Salutations.

  • There are no transitive functional dependencies, and hence our table is in 3NF.

  • In Table 3 Salutation ID is primary key, and in Table 1 Salutation ID is foreign to primary key in Table 3