Академический Документы
Профессиональный Документы
Культура Документы
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
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.
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
- 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.
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.
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.
EX: SUM(),COUNT(),AVERAGE(),MIN(),MAX() Scalar functions operate against a single value. Ex: UCASE(), LCASE(),LEN(),NOW()
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 Trigger.
Triggers are similar to stored procedure except it is executed automatically when any operations are occurred on the table.
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.
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.
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