DDL OPERATIONS: The various DDL commands are CREATE, ALTER and DROP. Let us learn about each DDL Command one by one with examples. CREATE Statement: The CREATE statement in SQL is used to create the database and the database objects like Tables, Views, Sequences, etc. Let us see how a database and table are created in SQL. Creating a database in SQL: Syntax: CREATE DATABASE DatabaseName; Example: CREATE DATABASE Demos; On executing this query, a database named "Demos" is created. Creating Table in SQL: Database is a collection of related tables and other objects. This implies that a table is a part of the database. Now, we have created the "Demos" database. And, we need to create a "Students" table in this database. By default, the master database is selected. Select Demos database from the dropdown list or alternatively you can use the following command: Use Demos; This ...
Popular posts from this blog
Database Normalization Normalization Normalization is a process of minimizing redundant data(duplicate) from database by decomposing the columns of a table into multiple tables. This process increases the number of tables in the database but it minimizes the redundant (duplicate), inaccurate and inconsistent data in database. Decomposed tables are connected using relationships (primary keys and foreign keys) to reduce the insert, update and delete anomalies. During normalization process, database designer decides the actual structure of the tables and their relationships. Every table in the database must satisfy all the normal forms. Normal Form Normal form defines a standard which must be followed for a good database design. During normalization process database designer converts the database tables in normal forms and check its functional dependency. Each normal form has some predefined standa...
Types of keys in DBMS What is Key? Keys are fields in a table which participate in below activities in RDBMS systems: To create relationships between two tables. To maintain uniqueness in a table. To keep consistent and valid data in database. Might help in fast data retrieval by facilitating indexes on column(s). SQL Server supports various types of keys, which are listed below: Candidate Key Primary Key Unique Key Alternate Key Composite Key Super Key Foreign Key Before discussing each type in brief, have a look on the below image used as an an example to define types of keys. Lets discuss each type in detail: Candidate Key Candidate key is a key of a table which can be selected as a primary key of the table. A table can have multiple candidate keys, out of which one can be selected as a primary key. Example : Employee_Id, License_Number and Passport_Number are candidate keys Primary Key Primary key is a candidate key of the table selected to...

Comments
Post a Comment