Select chapter



Basics (2.papers)
Data Types (2.papers)
Table-designing (1.papers)
Queries-Commands (3.papers)
String functions (2.papers)
Subqueries (1.papers)
Joins (1.papers)
Constraints (1.papers)
Triggers (1.papers)
Hide

Sponsored Links


  

sql table designing interview questions and answers

1
You need to create a table for storing Employees information which includes epmloyeeid, firstname, lastname and dob. Your table design must make sure to not allow duplicate or null values into employeeid column and firstname and lastname must not be null. Which of the table design suits for this requirement?
  1. create table employees 
    (
        employeeid int primary key,
        firstname varchar(40),
        lastname varchar(40),
        dob date
    )
  2. create table employees
    (
       employeeid int not null,
       firstname varchar(40) not null,
       lastname varchar(40) not null,
       dob date not null
    )
  3. create table employees
    (
       employeeid int primary key not null,
       firstname varchar(40) not null,
       lastname varchar(40) not null,
       dob date
    )
  4. create table employees
    (
       employeeid int primary key ,
       firstname varchar(40) not null,
       lastname varchar(40) not null,
       dob date
    )
Show Answer
Share Facebook gmail Twitter
2
You need to create a table for storing patients information which includes patientid, firstname, lastname and residentcity. Your table design must make sure to not allow duplicate or null values into patientid column and firstname and lastname must not be null. If user is not entering residentcity, SQL Server must insert Delhi as default city name.
Which of the following table design suits for this requirement?
  1. create table patients
    (
       patientid int primary key,
       firstname varchar(40) not null,
       lastname varchar(40) not null,
       residentcity varchar(60) default 'Delhi'
    )
  2. create table patients
    (
    patientid int primary key,
       firstname varchar(40) ,
       lastname varchar(40) ,
       residentcity varchar(60) 'Delhi'
    )
  3. create table patients
    (
    patientid int primary key,
       firstname varchar(40) ,
       lastname varchar(40) ,
       residentcity varchar(60) default value='Delhi'
    )
  4. None of the above.
Show Answer
Share Facebook gmail Twitter
3
You need to create a table for storing the details of students which includes studentid, firstname, lastname and age. Your table design must make sure that studentid's must be unique and age must be always between 18 to 26. Which of the following table design suits for this requirement?
  1. create table students
    (
       studentid int primary key,
       firstname varchar(40),
      lastname varchar(40),
      age tinyint
    )
  2. create table students
    (
       studentid int primary key,
       firstname varchar(40),
      lastname varchar(40),
      age tinyint default ( 18 and 26 )
    )
  3. create table students
    (
       studentid int primary key,
       firstname varchar(40),
      lastname varchar(40),
      age tinyint where age>=18 and age<=26 
    )
  4. create table studentsexp
    (
       studentid int primary key,
       firstname varchar(40),
      lastname varchar(40),
      age tinyint check (age>=18 and age<=26 )
    )
Show Answer
Share Facebook gmail Twitter
4
Identify the best suitable design for the below given table. Assuming table may get millions of records. Identify the best design which can eliminate inconsistent data and redundancy or data duplication?
Create table Patients
(
   pid int,
   fname varchar(40),
   lname varchar(40),
   bloodgroup varchar(30),
   statename varchar(40)
)
  1. The current table design itself is a good design.
  2. Create table Patients
    (
       pid int primary key,
       fname varchar(40) not null,
       lname varchar(40) not null,
       bloodgroup varchar(30) not null,
       statename varchar(40) not null
    )
  3. Create table Patients
    (
       pid int primary key,
       fname varchar(40) not null,
       lname varchar(40) not null,
       bloodgroup varchar(30) not null,
       statename varchar(40) foreign key references States (stateid) not null
    )
    create table States
    (
        stateid int primary key,
        statename varchar(40)
    )
  4. Create table Patients
    (
       pid int primary key,
       fname varchar(40) not null,
       lname varchar(40) not null,
       bgid varchar(30) forign key references bloogroups ( bgid ),
       stateid varchar(40) foreign key references States (stateid)
    )
    create table bloodgroups
    (
       bgid int primary key,
       bgname varchar(30) not null,
    )
    create table States
    (
        stateid int primary key,
        statename varchar(40) not null
    )
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Read more papers :