Posts

Explain DDL commands with example.

DDL consist of Commands to commands like CREATE, ALTER, TRUNCATE and DROP. These commands are used to create or modify the tables in SQL. CREATE : This command is used to create a new table in SQL. The user has to give information like table name, column names, and their datatypes.Example – We need to create a table for storing Student information of a particular College. Create syntax would be as below. CREATE TABLE Student_info ( College_Id number(2), College_name varchar(30), Branch varchar(10) ); Command-2 : ALTER : This command is used to add, delete or change columns in the existing table. The user needs to know the existing table name and can do add, delete or modify tasks easily. Syntax – Syntax to add a column to an existing table. ALTER TABLE table_name ADD column_name datatype; Example – In our Student_info table, we want to add a new column for CGPA. The syntax would be as below as follows. ALTER TABLE Student_info ADD CGPA number; Command-3 : TRUNCATE : This command is use...

Explain database languages

Database Languages are the set of statements, that are used to define and manipulate a database. A Database language has Data Definition Language (DDL), which is used to construct a database & it has Data Manipulation Language (DML), which is used to access a database.

Explain datatypes in SQL.

SQL Data Type is an attribute that specifies the type of data of any object. Each column, variable and expression has a related data type in SQL. You can use these data types while creating your tables. You can choose a data type for a table column based on your requirement.

Explain Enhanced/Extended ER diagram.

Enhanced entity-relationship models, also known as extended entity-relationship models, are advanced database diagrams very similar to regular ER diagrams. Enhanced ERDs are high-level models that represent the requirements and complexities of complex databases. In addition to the same concepts that ordinary ER diagrams encompass, EERDs include: Subtypes and supertypes (sometimes known as subclasses and superclasses) Specialization and generalization Category or union type Attribute and relationship inheritance

Explain any five relational algebra operators.

SELECT (σ): The SELECT operation is used for selecting a subset of the tuples according to a given selection condition. Sigma(σ)Symbol denotes it. It is used as an expression to choose tuples which meet the selection condition. Select operator selects tuples that satisfy a given predicate. Projection(π) The projection eliminates all attributes of the input relation but those mentioned in the projection list. The projection method defines a relation that contains a vertical subset of Relation. This helps to extract the values of specified attributes to eliminates duplicate values. (pi) symbol is used to choose attributes from a relation. This operator helps you to keep specific columns from a relation and discards the other columns. Rename (ρ) Rename is a unary operation used for renaming attributes of a relation. ρ (a/b)R will rename the attribute ‘b’ of relation by ‘a’. Union operation (υ) UNION is symbolized by ∪ symbol. It includes all tuples that are in tables A or in B. It also el...

. What is join? Explain the types of join with example.

A JOIN clause is used to combine rows from two or more tables, based on a related column between them Different Types of SQL JOINs Here are the different types of the JOINs in SQL: (INNER) JOIN: Returns records that have matching values in both tables LEFT (OUTER) JOIN: Returns all records from the left table, and the matched records from the right table RIGHT (OUTER) JOIN: Returns all records from the right table, and the matched records from the left table FULL (OUTER) JOIN: Returns all records when there is a match in either left or right table

Exaplain with example how ER diagram is converted into tables.

Step 1 − Conversion of strong entities For each strong entity create a separate table with the same name. Includes all attributes, if there is any composite attribute divided into simple attributes and has to be included. Ignore multivalued attributes at this stage. Select the p key for the table. Step 2 − Conversion of weak entity For each weak entity create a separate table with the same name. Include all attributes. Include the P key of a strong entity as foreign key is the weak entity. Declare the combination of foreign key and decimator attribute as P key from the weak entity. Step 3 − Conversion of one-to-one relationship For each one to one relation, say A and B modify either A side or B side to include the P key of the other side as a foreign key. If A or B is having total participation, then that should be a modified table. If a relationship consists of attributes, include them also in the modified table. Step 4 − Conversion of one-to-many relationship For each one to many rel...