1.
Which TCP/IP port does SQL Server run on? How can it be changed?
SQL Server runs on port 1433. It can be changed from the
Network Utility TCP/IP properties.
2.What is OLTP (Online Transaction Processing)?
In OLTP - online transaction processing systems relational
database design use the discipline of data modeling and generally follow the
Codd rules of data normalization in order to ensure absolute data integrity.
Using these rules complex information is broken down into its most simple
structures (a table) where all of the individual atomic level elements relate
to each other and satisfy the normalization rules.
3. What is SQL Profiler?
SQL Profiler is a graphical tool that allows system
administrators to monitor events in an instance of Microsoft SQL Server. You
can capture and save data about each event to a file or SQL Server table to
analyze later. For example, you can monitor a production environment to see
which stored procedures are hampering performances by executing too slowly.
Use SQL Profiler to monitor only the events in
which you are interested. If traces are becoming too large, you can filter them
based on the information you want, so that only a subset of the event data is
collected. Monitoring too many events adds overhead to the server and the
monitoring process and can cause the trace file or trace table to grow very
large, especially when the monitoring process takes place over a long period of
time.
4. What are the authentication modes in SQL Server? How can
it be changed?
Windows mode and Mixed Mode - SQL and Windows. To change
authentication mode in SQL Server click Start, Programs, Microsoft SQL Server
and click SQL Enterprise Manager to run SQL Enterprise Manager from the
Microsoft SQL Server program group. Select the server then from the Tools menu
select SQL Server Configuration Properties, and choose the Security page.
5. What is
normalization ?
Normalization is a design technique that is widely used as a guide in designing relational databases. Normalization is essentially a two step process that puts data into tabular form by removing repeating groups and then removes duplicated data from the relational tables
6. What is meant by
First Normal Form
A database is said to be in First Normal
Form when all entities have a unique identifier or key, and when every column
in every table contains only a single value and doesn't contain a repeating
group or composite field.
7. What is meant by
Second Normal Form
A database is in Second Normal Form when
it is in First Normal Form plus every non-primary key column in the table must
depend on the entire primary key, not just part of it, assuming that the
primary key is made up of composite columns.
8 .What is meant by
Third Normal Form
A database is in Third Normal Form when
it is in Second Normal Form and each column that isn't part of the primary key
doesn't depend on another column that isn't part of the primary key.
9. When to denormalize
?
Typically, transactional databases are
highly normalized. This means that redundant data is eliminated and replaced
with keys in a one-to-many relationship. Data that is highly normalized is
constrained by the primary key/foreign key relationship, and thus has a high
degree of data integrity. Denormalized data, on the other hand, creates
redundancies; this means that it's possible for denormalized data to lose track
of some of the relationships between atomic data items. However, since all the
data for a query is (usually) stored in a single row in the table, it is much
faster to retrieve.
10. How can you
performance tune your database ?
Ø Denormalize
your tables where appropriate.
Ø Proper
use of index columns: An index based on numeric fields is more efficient than
an index based on character columns.
Ø Reduce
the number of columns that make up a composite key.
Ø Proper
partitioning of tablespaces and create a special tablespace for special data
types like CLOB, BLOB etc.
Data access performance can be tuned by
using stored procedures to crunch data in the database server to reduce the
network overhead and also caching data within your application to reduce the
number of accesses.
11. How will you map
objects to a relational database ? How will you map class inheritance to
relational data model ?
Due to impedance
mismatch between object and relational technology you need to understand the
process of mapping classes (objects) and their relationships to tables and
relationships between them in a database. Classes represent both behavior and
data whereas relational database tables just implement data. Database schemas
have keys (primary keys to uniquely identify rows and foreign keys to maintain
relationships between rows) whereas object schema does not have keys and
instead use references to implement relationships to other objects.
Ø Classes
map to tables in a way but not always directly.
Ø An attribute of a class can be mapped to zero
or more columns in a database. Not all attributes are persistent.
Ø Some attributes of an object are objects
itself. For example an Employee object has an Address object as an attribute.
This is basically an association relationship between two objects.
Ø In its simple form an attribute maps to a
single column whereas each has same type (i.e. attribute is a string and column
is a char, or both are dates etc). When you implement mapping with different
types (attribute is a currency and column is a float) then you will need to be
able to convert them back and forth.
12. What is a view ?
Why will you use a view? What is an aggregate function ?
View
is a precompiled SQL query, which is used to select data from one or more
tables. A view is like a table but it doesn’t physically take any space (i.e.
not materialized).
Views are used for
Ø Providing
inherent security by exposing only the data that is needed to be shown to the
end user.
Ø Enabling re-use of SQL statements.
Ø Allows
changes to the underlying tables to be hidden from clients, aiding maintenance
of the database schema (i.e. encapsulation)
Ø Views
with multiple joins and filters can dramatically degrade performance because
views contain no data and any retrieval needs to be processed.
Ø The solution for this is to use materialized
views or create de-normalized tables to store data. This technique is quite
handy in overnight batch processes where a large chunk of data needs to be
processed. Normalized data can be read and inserted into some temporary
denormalized table and processed with efficiency.
13. What is a database
trigger ?
A trigger is a fragment of code that you
tell to run before or after a table is modified. There are typically three
triggering EVENTS that cause trigger to 'fire':
Ø INSERT
event (as a new record is being inserted into the database).
Ø UPDATE
event (as a record is being changed).
Ø DELETE event (as a record is being deleted).
Triggers can restrict access to specific data, perform logging, or audit access
to data.
14. How can you keep
track of all your database changes ?
If
you want to keep track of all changes to a particular record, such as who
modified the record, what kind of modification took place, and when the record
modification occurred then you can use triggers because you can capture every
action that occurred on a particular table. For example, an INSERT trigger
would fire when a particular database table has a record inserted.
15. What is the difference between “Stored Procedure” and
“Function”?
- A
procedure can have both input and output parameters, but a function can
only have input parameters.
- Inside a
procedure we can use DML (INSERT/UPDATE/DELETE) statements. But inside a
function we can't use DML statements.
- We can't
utilize a Stored Procedure in a Select statement. But we can use a
function in a Select statement.
- We can use
a Try-Catch Block in a Stored Procedure but inside a function we can't use
a Try-Catch block.
- We can use
transaction management in a procedure but we can't in a function.
- We can't
join a Stored Procedure but we can join functions.
- Stored
Procedures cannot be used in the SQL statements anywhere in the
WHERE/HAVING/SELECT section. But we can use a function anywhere.
- A
procedure can return 0 or n values (max 1024). But a function can return
only 1 value that is mandatory.
- A
procedure can't be called from a function but we can call a function from
a procedure.
No comments:
Post a Comment