Posts

What is basic SELECT statement?

Image
SELECT Statement A SELECT statement retrieves data from the database. With SELECT statement PROJECTION, SELECTION and JOIN can be performed on database tables. As data in relational database is stored in TABLES. TABLE has ROW and COLUMN structure. With SELECT statement all rows and all columns can be retrieved, this is known as PROJECTION. But, if rows and columns are retrieved on the basis of some condition, it is known as SELECTION. And suppose if some information is needed and that is stored in two or more different tables but are related, use JOINS to retrieve it from two or more tables. In SQL, basic SELECT statements are as follows: SELECT  * FROM  [ table_name ] ; SELECT   [ column1 ] ,  [ column2 ] ,  [ column3 ] ,   .....   FROM   [ table_name ] ; SELECT and FROM are known as clauses.  SELECT clause allows to specify columns to be selected from the database table.  FROM clause allows to specify table name that has those column to be s

What are different SQL statements?

SQL Statements Basically there are three types of SQL statements: 1. DDL  - Data Definition Language 2. DML - Data Manipulation Language 3. DCL  - Data Control Language  1) Data Definition Language: It is used to define the database structure. It includes following statements: CREATE Very basic is the create table statement, used to create a database table: CREATE TABLE [ table_name ] ( [ column1 ] datatype , [ column2 ] datatype , ..... ); ALTER ALTER statement is used to add, delete or modify database table columns. ALTER TABLE [ table_name ] ADD [ column_name ] datatype ; ALTER TABLE [ table_name ] DROP COLUMN [ column_name ] ; ALTER TABLE [ table_name ] MODIFY COLUMN [ column_name ] datatype ; DROP DROP statement is used to remove complete table definition with all data. DROP TABLE [ table_name ] ; 2) Data Manipulation Language: It is used to manipulate data in database. It includes following statements: SELECT Very basic SELE

What is SQL?

SQL SQL stands for Structured Query Language . SQL allows to access and manipulate data stored in relational database. In IT industry, it is also known as See-Quell. There are many implementation of SQL are available. Following are some of the DBs that provides SQL: MySQL ,  SQL Server,  MS Access,  Oracle, Postgres etc.

Differentiate between DDL and DML

DDL  DDL stands for Data Definition Language . DDL comprises of statements that are used to define the database structure or database schema. Following are DDL statements: CREATE - Statement used for creating database objects like TABLE, VIEW etc. ALTER - Statement used for modifying database structure. DROP - Statement used for deleting database objects. TRUNCATE - Statement for removing all records from a table and free the allocated space. RENAME - Statement for renaming database object. DML DM L stands for Data Manipulation Language . DML comprises of statements for managing data within the database. Following are DML statements: SELECT - Statement used to retrieve data from the TABLE. INSERT - Statement used to insert/push data in the TABLE. UPDATE - Statement used to update the existing data in the TABLE. DELETE - Statement used to delete data from the TABLE. 

What are the types of Functional Dependency?

Image
Types of Functional Dependency There are basically two types of functional dependency,  Trivial Functional Dependency Nontrivial Functional Dependency A functional dependency A  à  B is a trivial, if B is a subset of A.  It means dependent is  a subset of determinant or right term is a subset of left term. That is trivial, and is not so important. As B is a subset of A, which we already know and so we are not getting any new thing. A functional dependency  A  à  B is a nontrivial, if B is not a subset of A. It means dependent is not a subset of determinant or right term is not a subset of left term. That is nontrivial, and is important. As B is not a subset of A, which we don't know and so we are getting something new. Example of Trivial FD: {EM_NO, EM_NAME} à {EM_NAME} Example of Nontrivial FD: {EM_NO } à {EM_NAME}

What do you mean by Functional Dependency?

Image
Functional Dependency In a relation schema   R  with two attribute sets  A  and  B , where  A  and  B  are subsets of  R,  then relation R holds a functional dependency,                     Such that, if any valid relation r ( R ), with two tuples t1 and t2, has                                                                                       t1 [ A ] = t2 [ A ] then it should also have,                                                                              t1 [ B ] = t2 [ B ]                                    That means value of every tuple of attribute set  B  is dependent on value of every tuple of attribute set  A , or  That means every tuple of attribute  A  determines the value of every tuple of attribute set  B . In simple terms, if we know the value of A, then we can find the value of B in any relation R.  To understand it more clearly, let us take a simple example: Consider a table T1 with only two columns

Define the terms: domain, tuple, attribute and relation

Image
General Definitions Relation: A relation in a relational database is described as a table. Table is organized into rows and columns. Attribute: A column header of a table is known as attribute of a relation. Tuple: A row in a table represents the record of a relation and known as a tuple of a relation. Domain : A set of possible values for a given attribute is known as domain of a relation. A domain is atomic, that means values are indivisible. For example, set of values for attribute FirstName of an EMPLOYEE relation are atomic.