Looking for a Tutor Near You?

Post Learning Requirement »
x

Choose Country Code

x

Direction

x

Ask a Question

x

x
x
x
Hire a Tutor

Database Using SQL

Loading...

1,235 Views

Introduction to dabase concepts.

Prantik S / Kolkata

11 years of teaching experience

Qualification: MCA (Jaipur National University - [JNU], Jaipur - 2017)

Teaches: Basic Computer, Computer for official job, MS Office, School Level Computer, ICT Training, Computer Science, Information Practice, IT & Computer Subjects, BCA Tuition, IT, Computer, C / C++, C# (C Sharp), Java And J2EE, Python Programming, Visual Basic, BCA Subjects, Hardware Training, Networking, Java Script

Contact this Tutor
  1. Database Concept: A database is a collection of data that is organized in a manner that facilitates ease of access, as well as efficient management and updating. A database is made up of tables that store relevant information. For example, you would use a database, if you were to create a website like YouTube, which contains a lot of information like videos, usernames, passwords, comments. USERS Table 7 Database Tables VIDEOS Table 2 COMMENTS Table 3 A table stores and displays data in a structured format consisting of columns and rows that are similar to those seen in Excel spreadsheets. Databases often contain multiple tables, each designed for a specific purpose. For example, imagine creating a database table of names and telephone numbers. First, we would set up columns with the titles FirstName, LastName and TelephoneNumber. Each table includes its own set of fields, based on the data it will store.
  2. FirstName John David Chloe Emily James LastName Smith Williams Anderson Adams Roberts TelephoneNumber 715-555-1230 569-999-1719 715-777-2010 566-333-1223 763-777-2956 Note: A table has a specified number of columns but can have any number of rows. A primary key is a field in the table that uniquely identifies the table records. The primary key's main features: - It must contain a unique value for each row. - It cannot contain NULL values. For example, our table contains a record for each name in a phone book. The unique ID number would be a good choice for a primary key in the table, as there is always the chance for more than one person to have the same name. ID 1 2 3 4 5 FirstName John David Chloe Emily James LastName Smith Williams Anderson Adams Roberts TelephoneNumber 715-555-1230 569-999-1719 715-777-2010 566-333-1223 763-777-2956
  3. Note: - Tables are limited to ONE primary key each. - The primary key's value must be different for each row. Once you understand what a database is, understanding SQL is easy. SQL stands for Structured Query Language. SQL is used to access and manipulate a database. MySQL is a program that understands SQL. SQL can: - insert, update, or delete records in a database. - create new databases, table, stored procedures, views. - retrieve data from a database, etc. Note: SQL is an ANSI (American National Standards Institute) standard, but there are different versions of the SQL language. Most SQL database programs have their own proprietary extensions in addition to the SQL standard, but all of them support the major commands. Basic SQL Commands The SQL SHOW statement displays information contained in the database and its tables. This helpful tool lets you keep track of your database contents and remind yourself about the structure of your tables. For example, the SHOW DATABASES command lists the databases managed by the server. Throughout the tutorial we will be using the MySQL engine and the PHPMyAdmin tool to run SQL queries. Note: The easiest way to get MySQL and PHPMyAdmin is to install free tools like XAMPP or WAMP, which include all necessary installers. The SHOW TABLES command is used to display all of the tables in the currently selected MySQL database. SHOW COLUMNS displays information about the columns in a given table.
  4. The following example displays the columns in our customers table: SHOW COLUMNS displays the following values for each table column: Field ID Type int(11) Null NO NO Key PRI FirstName varchar(60) NO LastName varchar(60) NO City ZipC0de varchar(30) NO int(10) Default Extra NULL NULL NULL NULL NULL Field: column name Type: column data type Key: indicates whether the column is indexed Default: default value assigned to the column Extra: may contain any additional information that is available about a given column The columns for the customers table have also been created using the PHPMyAdmin tool. The SELECT statement is used to select data from a database. The result is stored in a result table, which is called the result-set. Below is the data from our customers table: ID 1 2 3 4 5 FirstName John David Chloe Emily James LastName Smith Williams Anderson Adams Roberts City New York Los Angeles Chicago Houston Philadelphia ZipCode 10199 90052 60607 77201 19104
  5. A query may retrieve information from selected columns or from all columns in the table. To create a simple SELECT statement, specify the name(s) of the column(s) you need from the table. Syntax of the SQL SELECT Statement: SELECT column list FROM table name The following SQL statement selects the FirstName from the customers table: SELECT FirstName FROM customers FirstName John David Chloe Emily James - column list includes one or more columns from which data is retrieved - table-name is the name of the table from which the information is retrieved Note: A SELECT statement retrieves zero or more rows from one or more database tables.