Databases Questions & Answers

1.      What are two methods of retrieving SQL? 

2.      What cursor type do you use to retrieve multiple recordsets?

3.      What action do you have to perform before retrieving data from the next result set of a stored procedure?

Move the cursor down one row from its current position. A ResultSet cursor is initially positioned before the first row. Before you can get to the first row, you would need to Move the cursor down by one row ( For ex: in java the first call to next makes the first row the current row; the second call makes the second row the current row, and so on).

4.      What is the basic form of a SQL statement to read data out of a table?

SELECT * FROM table_name;

5.      What structure can you have the database make to speed up table reads?

The question is not correct. "What structure can you have the database make to speed up table reads?" It is not clear what exactly the term "structure" means in this case. Follow the rules of DB tuning we have to:

1) properly use indexes ( different types of indexes)

2) properly locate different DB objects across different tablespaces, files and so on.

3) Create a special space (tablespace) to locate some of the data with special datatypes( for example CLOB, LOB and ...)

6.      What is a "join"?

Joins merge the data of two related tables into a single result set, presenting a denormalized view of the data.

7.      What is a "constraint"?

  A constraint allows you to apply simple referential integrity checks to a table. There are 5 primary types of constraints that are currently supported by SQL Server:

  PRIMARY/UNIQUE - enforces uniqueness of a particular table column.

  DEFAULT - specifies a default value for a column in case an insert operation does not provide one.

  FOREIGN KEY - validates that every value in a column exists in a column of another table.

  CHECK - checks that every value stored in a column is in some specified list

  NOT NULL - is a constraint which does not allow values in the specific column to be null. And also it is the only constraint which is not a table level constraint.

8.      What is a "primary key"?

Primary Key is a type of a constraint enforcing uniqueness and data integrity for each row of a table. All columns participating in a primary key constraint must possess the NOT NULL property.

9.      What is a "functional dependency"? How does it relate to database table design?

What functional dependence in the context of a database means is that: Assume that a table exists in the database called TABLE with a composite primary key (A, B) and other non-key attributes (C, D, E). Functional dependency in general, would mean that any non-key attribute - C D or E being dependent on the primary key (A and B) in our table here.

  Partial functional dependency, on the other hand, is another corollary of the above, which states that all non-key attributes - C D or E - if dependent on the subset of the primary key (A and B) and not on it as a whole.

  Example :

  ----------

  Fully Functional Dependent : C D E --> A B

  Partial Functional dependency : C --> A, D E --> B

  Hope that helps!

10.  What is a "trigger"?

A trigger is a database object directly associated with a particular table. It fires whenever a specific statement/type of statement is issued against that table. The types of statements are insert, update, delete and query statements. Basically, trigger is a set of SQL statements that execute in response to a data modification/retrieval event on a table.

Other than table triggers there are also schema and database triggers. These can be made to fire when new objects are created, when a user logs in, when the database shutdown etc. Table level triggers can be classified into row and statement level triggers and those can be further broken down into before and after triggers. Before triggers can modify data.

11.  What is "index covering" of a query?

A nonclustered index that includes (or covers) all columns used in a query is called a covering index. When SQL server can use a nonclustered index to resolve the query, it will prefer to scan the index rather than the table, which typically takes fewer data pages. If your query uses only columns included in the index, then SQL server may scan this index to produce the desired output.

12.  What is a SQL view?

View is a precomplied 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. View is a good way to present data in a particular format if you use that query quite often.

View can also be used to restrict users from accessing the tables directly.

A view otherwise known as a virtual table is a mere window over the base tables in the database. This helps us gain a couple of advantages:

1) Inherent security exposing only the data that is needed to be shown to the end user

2) Views are updateable based on certain conditions. For example, updates can only be directed to one underlying table of the view. After modification if the rows or columns don't comply with the conditions that the view was created with, those rows disappear from the view. You could use the CHECK OPTION with the view definition, to make sure that any updates to make the rows invalid will not be permitted to run.

3) Views are not materialized (given a physical structure) in a database. Each time a view is queried the definition stored in the database is run against the base tables to retrieve the data. One exception to this is to create a clustered index on the view to make it persistent in the database. Once you create a clustered index on the view, you can create any number of non-clustered indexes on the view.

Databases Questions & Answers的更多相关文章

  1. UNIX command Questions Answers asked in Interview

    UNIX or Linux operating system has become default Server operating system and for whichever programm ...

  2. 问题与解答 [Questions & Answers]

    您可以通过发表评论的方式提问题, 我如果有时间就会思考,  并给出答案的链接. 如果您学过Latex, 发表评论的时候请直接输入Latex公式; 反之, 请直接上传图片 (扫描.拍照.mathtype ...

  3. Financial Information Exchange (FIX) Protocol Interview Questions Answers[z]

    What do you mean by Warrant?Warrant is a financial product which gives right to holder to Buy or Sel ...

  4. 转----------数据库常见笔试面试题 - Hectorhua的专栏 - CSDN博客

    数据库基础(面试常见题) 一.数据库基础 1. 数据抽象:物理抽象.概念抽象.视图级抽象,内模式.模式.外模式 2. SQL语言包括数据定义.数据操纵(Data Manipulation),数据控制( ...

  5. 40 Questions to test your skill in Python for Data Science

    Comes from: https://www.analyticsvidhya.com/blog/2017/05/questions-python-for-data-science/ Python i ...

  6. Python 绝对简明手册

    Python 绝对简明手册 help(函数名)来获取相关信息 另外,自带的文档和google也是不可少的 2. 基本语法2.1. if / elif / else x=int(raw_input(&q ...

  7. 【Python五篇慢慢弹】数据结构看python

    数据结构看python 作者:白宁超 2016年10月9日14:04:47 摘要:继<快速上手学python>一文之后,笔者又将python官方文档认真学习下.官方给出的pythondoc ...

  8. python数据结构

      . 数据结构¶ .1. 深入列表¶ 链表类型有很多方法,这里是链表类型的所有方法: list.append(x) 把一个元素添加到链表的结尾,相当于 a[len(a):] = [x] . list ...

  9. python 字典 注意点

    dict()构造函数直接从键-值对序列创建字典: >>> >>> dict([('sape', 4139), ('guido', 4127), ('jack', 4 ...

随机推荐

  1. Unity中SendMessage和Delegate效率比较

    网上直接搜的代码.需要的使用也简单,所以就不过多说明. 但是网上都说,他们之间的差距,delegate比较快,效果高.怎么个高法呢?还是自己来测试下时间. 故此, 个人之用来比较下时间差别. 一.直接 ...

  2. chmod 777 修改权限

    http://william71.blogbus.com/logs/33484772.html 在Unix和Linux的各种操作系统下,每个文件(文件夹也被看作是文件)都按读.写.运行设定权限.例如我 ...

  3. Java自动类型转换

    ■ 自动类型转换:容量小的数据类型可以自动转换为容量大的数据类型. ■ 特例:可以讲整型常量直接赋给byte,short,char等类型变量,而不需要强制类型转换,只要不超出其表数范围. ■ 强制类型 ...

  4. android基础---->Fragment的使用

    碎片(Fragment)是一种可以嵌入在活动当中的UI 片段,它能让程序更加合理和充分地利用大屏幕的空间,因而在平板上应用的非常广泛. Fragment的基础例子

  5. codeforce 148D. Bag of mice[概率dp]

    D. Bag of mice time limit per test 2 seconds memory limit per test 256 megabytes input standard inpu ...

  6. 音频的录制和播放功能(audio) ---- HTML5+

    模块:audio Audio模块用于提供音频的录制和播放功能,可调用系统的麦克风设备进行录音操作,也可调用系统的扬声器设备播放音频文件.通过plus.audio获取音频管理对象. 应用场景:音频录制, ...

  7. HDCMS导航高亮显示!解决办法

    第一种方法:(传递class) <channel type='top' row='8' class='cur' > <li class='{$field.class}'> &l ...

  8. [shell]用shell脚本将本地文件夹与ftp上的文件夹同步

    需求说明 最近在AIX上做开发,开发机器在office网段,测试机器在lab网段,不能互相通讯,只能通过特定的ftp来传文件. 每次上传的机器都要做:登录ftp,进入我的目录,上传:下载的机器都要做: ...

  9. chinese-typesetting:更好的中文文案排版

    欢迎指正.GitHub 地址:https://github.com/jxlwqq/chinese-typesetting 更好的中文文案排版 统一中文文案.排版的相关用法,降低团队成员之间的沟通成本, ...

  10. pandas的replace方法

    就是将一个值替换为另一个值,以前我用的是赋值方式,这里应该效率会高. 1.说明: 语法:replace(self, to_replace=None, value=None, inplace=False ...