Professional Documents
Culture Documents
Dbms
Dbms
In the above table we can clearly see that the subject column has two
values. Thus it violated the 1NF. Now if we apply 1NF the above table
can be converted as below
The first condition in 2NF is that the table should be in 1NF, the table
also should not contain partial dependency.
The primary key for this table is a composition of two columns which is student_id &
subject_id but the teacher and subject only depends on subject_id. This is Partial
Dependency, where an attribute in a table depends on only a part of the primary
key and not on the whole key.
405 1203 50
405 1325 45
505 1325 55
In the above table match no is the primary key. The match and
stadium column depends on match no but the population column
depends on the stadium.This is Transitive Dependency. When a non-
prime attribute depends on other non-prime attributes rather than
depending upon the prime attributes or primary key.
stadium population
Tu stadium 5000
ALTER
ALTER is used to modify existing database data structures (database, table).
To remove column from a table.
Syntax: alter table table_name drop coumn_name;
Example: alter table student drop gpa;
DML statements (Data Manipulation Language):
DML is a Data Manipulation Language, it’s used to build SQL queries to manipulate (select,
insert, update, delete etc.) data in the database.
Select
Update
Insert
Delete
SELECT
SELECT query is used to retrieve a data from SQL tables.
Syntax: select column1,column2 from table_name;
Example: select * from student;
INSERT
INSERT command is used to add new rows into the database table.
Syntax: insert into table_name values ( value1, value2,….);
Example: insert into student values (1, ‘ram’);
UPDATE
UPDATE statement modifies records into the table.
Syntax: update table_name set column=value where condition;
Example: update student set gpa= 2.6 where roll=1;
DELETE
DELETE query removes entries from the table.
Syntax: delete from table_name where condition;
Example: delete from student where roll=1;