Hi everybody,
I am Hugo . I want to know something more about SQL.
please can anybody give me some idea about some basic SQl questions?
First of all i want to know,
1.What is the SQL Data Manipulation Language(DML)?
2.What is the SQL Data Defenition Language(DDL)?

Hi Hug,
I think i can help you,
SQL is syntax for executing queries and updating,inserting and deleting records.These query and update commands together form the DML.
And, the DDL part of SQL provides syntax for creating or deleting database tables.Also define keys,specify links between tables and impose constraints between database tables.

DML or Data manipulation language is nothing but "How do you manipulate the data in a table". You can manipulate the data in these ways.
1. Selecting the data from the table (Select)
2. Inserting the data to the table (Insert)
3. Updating the data in the table (Update)
4. Deleting the data from the table (Delete)

Data definition language means how do you define/change the database objects. They are,
1. Creating a database object Eg.Table (Create)
2. Changing the table structure (Alter)
3. Deleting/Dropping the table (Drop).


Edit: ravisen22 you beat me by 2 mins. :)

Hello...Hug..
If you want , i will give some examples also.
DML part of SQL are:
1.SELECT-extracts data from a database table.
2.UPDATE-update data in a database table.
3.DELETE-delete data from a database table.
4.INSERT INTO-inserts new data into a database table.

DDL part of SQL are:
1.CREATE TABLE-creates a new database table.
2.ALTER TABLE-alters a database table.
3.DROP TABLE-deletes a database table.
4-CREATE INDEX-creates an index.
5.DROP INDEX-deletes an index.

Hi,
Thank you ravise22.
And thank you nav33n.
Both of you gave me some good knowledgeabout SQL languages like DDL and DML. At the same time both of you gave me suffiecient examples also. Thanx.

Hey,
I have some more doubts also.
One is ,
What r normalization and denormalization?
And,What is an index, and how is it used to improve perfomance?

Normalization is a difficult theory to explain. You should read it yourself to understand it better. But in short, normalization is a process following which, you can optimize the performance of your database. (Eg. By avoiding obsolete data, duplication, and by using primary keys, etc).

Index is just like the index of a book. If you want a particular topic in a book, you refer the index page of that book and go to that respective topic. Index in database, is kinda same. It increases the speed w.r.t the operations on a table.

You should go through http://w3schools.com/sql/sql_intro.asp :)

What is an alternate key in a table ?
Please tell more about foreign key an primary key ?
Please show one example that how we can eliminate duplicate column(s) from one table?

Hi
In a database table,apart from primary key columns,other column, may need to be a key.These are alternate key.This column value may or may not be unique one.
A key column in a table that identifies records in a different table is called foreign key.

To avoid duplication in column(s) we can create it with unique costraint. Constraint is nothing but rules that you can impose on the columns to be unique or not null etc. To create a unique column you can have the codes like:
create table mytable(col1 datatype unique, col2 datatype,...)

Oh, btw, if you have any duplicate rows, *I dont think it is possible to delete only the duplicate rows. You have to manually (:() delete them. *

Edit: The only way i can think of is, create a dummy table(new_table). Copy distinct rows from old_table to new_table. Truncate old_table. Copy the records from new_table to old_table. I cant think of ANY query to delete duplicate records from a table.

To avoid duplication in column(s) we can create it with unique costraint. Constraint is nothing but rules that you can impose on the columns to be unique or not null etc. To create a unique column you can have the codes like:
create table mytable(col1 datatype unique, col2 datatype,...)

Or declare it as a primary key. Primary key is a combination of both "not null" and "unique" constraints.

Hi am zeal,
Can anybody please explain to me what GROUP BY in SQL really does?

For aggregate functions like SUM, AVG, MIN, MAX etc, you should use group by clause. Group by clause groups the records depending upon the table field you mention. Say, for eg, you have a table. This table has 2 columns, student_marks and subject. You want to know the average marks of each subject. You can do this using the group by clause. select avg(student_marks) from table group by subject This will calculate the average marks of each subject and shows the average marks for each subject.
Cheers,
Nav

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.