Вы находитесь на странице: 1из 9

DBMS

BASICS
What is RDBMS? Explain its features.
RDBMS is a database management system based on relational model defined by E.F.Codd. in which data is stored in the form of rows and columns. The relations among tables are also stored in the form of the table. Features It stores data in tables. Tables have rows and column. These tables are created using SQL. And data from these tables are also retrieved using SQL Provides facility primary key, to uniquely identify the rows - Creates indexes for quicker data retrieval - Provides a virtual table creation in which sensitive data can be stored and simplified query can be applied.(views) - Sharing a common column in two or more tables(primary key and foreign key) - Provides multi user accessibility that can be controlled by individual users

Explain the difference between DBMS and RDBMS.


DBMS offers organized way of storing, managing and retrieving information.

RDBMS provides all features of DBMS with added referential integrity concept. DBMS: A DBMS is a storage area that persist the data in files. To perform the database operations, the file should be in use. Relationship can be established between 2 files. There are limitations to store records in a single database file depending upon the database manager used. DBMS allows the relations to be established between 2 files. Data is stored in flat files with metadata. DBMS does not support client / server architecture. DBMS does not follow normalization. Only single user can access the data. DBMS does not impose integrity constraints. ACID properties of database must be implemented by the user or the developer RDBMS: RDBMS stores the data in tabular form. It has additional condition for supporting tabular structure or data that enforces relationships among tables.

RDBMS supports client/server architecture. RDBMS follows normalization. RDBMS allows simultaneous access of users to data tables. RDBMS imposes integrity constraints. ACID properties of the database are defined in the integrity constraints.

Define referential integrity.


t is the rules that are applied when the relationships are created. It ensures integrity of data and prevents inconsitent data into the tables.

Or Referential integrity is a RDBMS concept and ensures the relationships among tables remain consistent. Data integration (correctness of data) and preventing inconsistent data are ensured by referential integrity. This concept has two keys namely primary key and foreign key. Among the tables, one table should contain primary key and other(s), foreign key. Foreign key specifies that the values in that column must not be other than the values available in the table which has primary key.

NORMALISATION
What are the benefits of normalizing database?
it helps to avoid duplicate entries. It allows saving storage space. It enhances the performance of queries.

The process of searching, sorting and creating indexes is faster - More tables can be derived for clear and needed tables to be designed - Clustering indexes can be created which provides the flexibility in fine tuning queries. - Less redundant data and fewer null values will make the database more compact. - The indexes of tables make data modification commands execution much faster. - If redundant data is not maintained, the execution of triggers is quicker. - Normalization facilitates in reducing data modification anomalies

What is normalization?
Normalization is the way of organizing data in a database by removing redundancy and inconsistent dependency. Database normalization has the rules to be followed while creating databases. Each rule is called as normal form. First Normal form states - Remove duplicate column and identify each set of related data with a primary key. Second normal form - Create relationship between master and master detail tables using foreign key. Third normal form - Remove the fields that do not depend on the primary key.

It is the process of organizing data into related table. To normalize database, we divide database into tables and establish relationships between the tables. It reduces redundancy. It is done to improve performance of query.

OR
Normalization is the technique for designing database tables to eliminate data redundancy, to safe guard the database against certain anomalies (structural problems). It is a step-by-step breakdown of data structure complexity into simple structure that facilitates no loss to information and relationship.

What is denormalization?
The process of adding redundant data to get rid of complex join, in order to optimize database performance. This is done to speed up database access by moving from higher to lower form of normalization.

OR Redundant data addition for optimizing the performance of a database, denormalization is the process. The inefficiencies those inherit in RDBMS software are addressed with denormalization. It is a process of combining data into a single table. Denormalization structures are used in databases for providing quick access for a specific user needs.

ER
What is an Entity-Relationship diagram?
It is a graphical representation of tables with the relationship between them.

Or R diagram is a conceptual and abstract representation of data and entities. ER is a data modeling process, which is to produce a conceptual schema of a system, often an RDBMS and the needs in top down fashion. ER diagrams are derived by using this model.

The logical structure of databases is illustrated in the ER diagrams. These diagrams use symbols for representing different types of information. Boxes are used for representing entities. Rhombuses are used for representing relationships and ovals are used for representing attributes. For a good database creation it is essential to have ER diagram. These diagrams follow top-down approach. To focus on how the database really works with all data flow and interactions, the best pattern is ER Diagrams

Explain the types of relationships in database.


There are four relationships in database. 1)One to One: One entity is associated with another entity. For Ex: Each employee is associated with one department One to one is implemented using single table by establishing relationship between same type of columns in a table.

- 2) One to Many: One entity is associated with many other entities. For Ex: A company is associated with all working employees in one branch/office/country. implemented using two tables with primary key and foreign key relationships.

-3) Many to One: Many entities are associated with only one entity. For Ex: Many employees are associated with one project. - 4) Many to Many: Many entities are associated with many other entities. For Ex: In a company many employees are associated with multiple projects(completed/existing), and at the same time, projects are associated with multiple employees. mplemented using a junction table. The keys from both the tables form composite primary key of the junction table

SQL
Define SQL.
SQL stands for Structured Query Language. It allows access, insert/update/delete records and retrieve data from the database. . A specialized language for sending queries to database

Structured Query Language is a relational database language, designed for managing data OR
Structured query language, SQL is an ANSI standard language that provides commands to access and update databases.

Explain DML and DDL statements.


Data definition language is used to define and manage all attributes and properties of a database.

Most DDL statements include following commands CREATE ALTER DROP

Data Manipulation Language Data manipulation language is used to select, insert, update, and delete data in the objects defined with DDL. Or
DDL-Data Definition Language: DDL is the syntax of SQL for defining the way the database is organized physically. Database meta data is created by DDL of SQL. The tables, views, indexes, sequences, triggers, database users (by DBA) are well defined using DDL statement, CREATE.

Modification for the metadata or schema is done by ALTER command and removing database objects is done by DROP command. DML-Data Manipulation Language: DML statements, INSERT, DELETE, UPDATE AND SELECT INTO are used for data manipulation, adding new rows, deleting unwanted rows and changing data in the rows. These are known as SQL-change statements. DML does not change the schema of database.

What is sub-query?
A query within a query is defined as a sub-query. A sub query is executed by enclosing it within another query. Sub queries are used for returning single row as an atomic value. A sub query is nested in DML statements, and enclosed in parenthesis.

What is "correlated subqueries"?


In "correlated subqueries", the result of outer query is passed to the subquery and the subquery runs for each row.

Unlike sub query, a correlated sub query is dependent upon the outer query, which returns a value. When a reference to the outer query is found in the sub query, then the outer query will execute first, and the result will be returned to the correlated sub query.

Define aggregate and scalar functions.


Aggregate Functions return a single value by operating against a group of values.

EX: SUM(),COUNT(),AVERAGE(),MIN(),MAX() Scalar functions operate against a single value. Ex: UCASE(), LCASE(),LEN(),NOW()

What is a join and explain different types of joins.


Joins are utilized to get the results from two or more tables. There are two types of joins available. 1. Outer Join: Outer join has two categories left outer join and right outer join. In this join functionality, two or more tables are joined by including blank rows in the specified side, once the criterion satisfies. The combination of left outer join and right outer join is simple outer join. 2. Inner Join: In this join functionality, two or more tables are joined by leaving the blank rows for checking. Other than these two joins, there areNatural Join: This join is the Cartesian product.

Equi Join: A condition includes an operator NonEqui Join: They are conditional joins which does not use their conditions.

Define constraints.
Constraints enforce integrity of the database. Constraints can be of following types Not Null Check Unique Primary key Foreign key

Define stored procedure.


Stored procedure is a set of pre-compiled SQL statements, executed when it is called in the program.

Define Trigger.
Triggers are similar to stored procedure except it is executed automatically when any operations are occurred on the table.

Define Truncate and Delete commands


Truncate
Truncate command is used to remove all rows of the column. The removed records are not recorded in the transaction log. It is the fast way to remove all the records from the table. The records once removed cant be rolled back. It cant activate trigger. It resets the identity of the column.

Delete
Delete command removes records one at a time and logs into the transaction log. It can be used with or without where clause. The records can be rolled back. It activates trigger. It doesnt reset the identity of the column. TRUNCATE This is also a logged operation but in terms of deallocation of data pages. Cannot TRUNCATE a table that has foreign key DELETE This is a logged operation for every row. Any row not violating a constraint can be

constraints. Resets identity column to the default starting value. Removes all rows from a table. Cannot be Rolled back. DDL command

Deleted. Does not reset the identity column. Starts where it left from last. Used delete all or selected rows from a table based on WHERE clause. Need to Commit or Rollback DML command

KEYS
Primary Key: Primary key is used for unique identification of each row in a table. Unique and not null values only are accepted to persist in primary key. OR A column or combination of columns that identify a row of data in a table is Primary Key.

Primary key and unique key


Both are used to provide uniqueness of the column. Primary key creates clustered key on the column by default whereas unique key creates nonclustered index by default. Primary doesn't allow NULL values whereas unique key can allow one NULL value. Foreign Key: Foreign Key identifies a column with the primary key column of another table (parent table) for storing data. The values in the foreign key must be the values of primary key of other columns. Thus it ensures the data integrity correct data. OR A key in a table that identifies records in other table in called a foriegn key.

Define alternate key.


There can be a key apart from primary key in a table that can also be a key. This key may or may not be a unique key. For example, in an employee table, empno is a primary key, empname is a alternate key that may not be unique but still helps in identifying a row of the table.

OR An alternate key is similar to a primary key. It accepts null values; where as the primary key does not. The null values can be submitted to the attribute in a tuple.

TRANSACTIONS OTHERS
What is cursor?
A Cursor is a database object that represents a result set and is used to manipulate data row by row. When a cursor is opened, it is positioned on a row and that row is available for processing.

Or
A cursor is a variable that represents an area where the result of a query is stored. A single row query is stored in a cursor called implicit cursor. If a relation that fetches multiple rows, the cursor is called explicit cursor. An explicit cursor is handled in a PL/SQL block and each row can be handled by putting the relation fetched by the cursor, in a loop.

Explain the cursor types.


There are two types of cursors: 1. Implicit Cursor: It is declared automatically when the SQL statement is executed. User is not aware of what is happening and cannot control or process the information available in the implicit cursor. 2. Explicit Cursor: Explicit cursor is defined in PL/SQL block which is to handle the query that fetches more than one row. The developer/programmer needs to declare, open the cursor. Then he/she needs to fetch and process sequentially all the rows and close it.

Difference between clustered and non-clustered index.


A clustered index is unique for a given table. The actual data is at the leaf level of a clustered index and data is resorted. Non-clustered index has the leaf level which has pointers to the data in the rows, so that one table can have as many as non-clustered indexes in a database. We can have only one clustered index in a table but we can have many non-clustered index in a table.

What are the restrictions applicable while creating views?


Views can be created referencing tables and views only in the current database. A view name must not be the same as any table owned by that user. You can build views on other views and on procedures that reference views. Rules or DEFAULT definitions can't be associated with views. Only INSTEAD OF triggers can be associated with views.

The query that defines the view cannot include the ORDER BY, COMPUTE, or COMPUTE BY clauses or the INTO keyword. You cannot define full-text index definitions for views. You cannot create temporary views You cannot create views on temporary tables.

The following are the restrictions for creating views in RDBMS; - Views can be created only in the current database. - A computed value can not be changed in a view - INSERT and DELETE statements may be used subject to the integrity constraints

Вам также может понравиться