Sql

413
-1

Published on

detailed ppt on sql

Published in: Education, Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
413
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
0
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide
  • Frequently, presenters must deliver material of a technical nature to an audience unfamiliar with the topic or vocabulary. The material may be complex or heavy with detail. To present technical material effectively, use the following guidelines from Dale Carnegie Training®.   Consider the amount of time available and prepare to organize your material. Narrow your topic. Divide your presentation into clear segments. Follow a logical progression. Maintain your focus throughout. Close the presentation with a summary, repetition of the key steps, or a logical conclusion.   Keep your audience in mind at all times. For example, be sure data is clear and information is relevant. Keep the level of detail and vocabulary appropriate for the audience. Use visuals to support key points or steps. Keep alert to the needs of your listeners, and you will have a more receptive audience.
  • In your opening, establish the relevancy of the topic to the audience. Give a brief preview of the presentation and establish value for the listeners. Take into account your audience’s interest and expertise in the topic when choosing your vocabulary, examples, and illustrations. Focus on the importance of the topic to your audience, and you will have more attentive listeners.
  • If you have several points, steps, or key ideas use multiple slides. Determine if your audience is to understand a new idea, learn a process, or receive greater depth to a familiar concept. Back up each point with adequate explanation. As appropriate, supplement your presentation with technical support data in hard copy or on disc, e-mail, or the Internet. Develop each point adequately to communicate with your audience.
  • In your opening, establish the relevancy of the topic to the audience. Give a brief preview of the presentation and establish value for the listeners. Take into account your audience’s interest and expertise in the topic when choosing your vocabulary, examples, and illustrations. Focus on the importance of the topic to your audience, and you will have more attentive listeners.
  • If you have several points, steps, or key ideas use multiple slides. Determine if your audience is to understand a new idea, learn a process, or receive greater depth to a familiar concept. Back up each point with adequate explanation. As appropriate, supplement your presentation with technical support data in hard copy or on disc, e-mail, or the Internet. Develop each point adequately to communicate with your audience.
  • If you have several points, steps, or key ideas use multiple slides. Determine if your audience is to understand a new idea, learn a process, or receive greater depth to a familiar concept. Back up each point with adequate explanation. As appropriate, supplement your presentation with technical support data in hard copy or on disc, e-mail, or the Internet. Develop each point adequately to communicate with your audience.
  • If you have several points, steps, or key ideas use multiple slides. Determine if your audience is to understand a new idea, learn a process, or receive greater depth to a familiar concept. Back up each point with adequate explanation. As appropriate, supplement your presentation with technical support data in hard copy or on disc, e-mail, or the Internet. Develop each point adequately to communicate with your audience.
  • If you have several points, steps, or key ideas use multiple slides. Determine if your audience is to understand a new idea, learn a process, or receive greater depth to a familiar concept. Back up each point with adequate explanation. As appropriate, supplement your presentation with technical support data in hard copy or on disc, e-mail, or the Internet. Develop each point adequately to communicate with your audience.
  • If you have several points, steps, or key ideas use multiple slides. Determine if your audience is to understand a new idea, learn a process, or receive greater depth to a familiar concept. Back up each point with adequate explanation. As appropriate, supplement your presentation with technical support data in hard copy or on disc, e-mail, or the Internet. Develop each point adequately to communicate with your audience.
  • If you have several points, steps, or key ideas use multiple slides. Determine if your audience is to understand a new idea, learn a process, or receive greater depth to a familiar concept. Back up each point with adequate explanation. As appropriate, supplement your presentation with technical support data in hard copy or on disc, e-mail, or the Internet. Develop each point adequately to communicate with your audience.
  • If you have several points, steps, or key ideas use multiple slides. Determine if your audience is to understand a new idea, learn a process, or receive greater depth to a familiar concept. Back up each point with adequate explanation. As appropriate, supplement your presentation with technical support data in hard copy or on disc, e-mail, or the Internet. Develop each point adequately to communicate with your audience.
  • If you have several points, steps, or key ideas use multiple slides. Determine if your audience is to understand a new idea, learn a process, or receive greater depth to a familiar concept. Back up each point with adequate explanation. As appropriate, supplement your presentation with technical support data in hard copy or on disc, e-mail, or the Internet. Develop each point adequately to communicate with your audience.
  • If you have several points, steps, or key ideas use multiple slides. Determine if your audience is to understand a new idea, learn a process, or receive greater depth to a familiar concept. Back up each point with adequate explanation. As appropriate, supplement your presentation with technical support data in hard copy or on disc, e-mail, or the Internet. Develop each point adequately to communicate with your audience.
  • Determine the best close for your audience and your presentation. Close with a summary; offer options; recommend a strategy; suggest a plan; set a goal. Keep your focus throughout your presentation, and you will more likely achieve your purpose.
  • Sql

    1. 1. SQL Server - Design and Implementation
    2. 2. <ul><li>SQL stands for S tructured Q uery L anguage. </li></ul><ul><li>It is the most commonly used relational database language today. </li></ul><ul><li>SQL works with a variety of different fourth-generation (4GL) programming languages, such as Visual Basic and .NET </li></ul>An Overview of SQL
    3. 3. <ul><li>Data Manipulation </li></ul><ul><li>Data Definition </li></ul><ul><li>Data Administration </li></ul><ul><li>All are expressed as an SQL statement or command. </li></ul>SQL is used for:
    4. 4. <ul><li>SQL Must be embedded in a programming language, or used with a 4GL like VB or .NET Technologies </li></ul><ul><li>SQL is a free form language so there is no limit to the number of words per line or fixed line break. </li></ul><ul><li>Syntax statements, words or phrases are always in lower case; keywords are in uppercase. </li></ul>SQL Requirements
    5. 5. <ul><li>Represent all info in database as tables </li></ul><ul><li>Keep logical representation of data independent from its physical storage characteristics </li></ul><ul><li>Use one high-level language for structuring, querying, and changing info in the database </li></ul><ul><li>Support the main relational operations </li></ul><ul><li>Support alternate ways of looking at data in tables </li></ul><ul><li>Provide a method for differentiating between unknown values and nulls (zero or blank) </li></ul><ul><li>Support Mechanisms for integrity, authorization, transactions, and recovery </li></ul>SQL is a Relational Database A Fully Relational Database Management System must:
    6. 6. <ul><li>SQL represents all information in the form of tables </li></ul><ul><li>Supports three relational operations: selection, projection, and join . These are for specifying exactly what data you want to display or use </li></ul><ul><li>SQL is used for data manipulation, definition and administration </li></ul>Design
    7. 7. Basic structure of an SQL query
    8. 8. Table Design Rows describe the Occurrence of an Entity Columns describe one characteristic of the entity Tables are the basic structure where data is stored in the database. Name Address Jane Doe 123 Main Street John Smith 456 Second Street Mary Poe 789 Third Ave
    9. 9. SQL Constraints <ul><li>Common types of constraints include the following: </li></ul><ul><li>NOT NULL Constraint : Ensures that a column cannot have NULL value. </li></ul><ul><li>DEFAULT Constraint : Provides a default value for a column when none is specified. </li></ul><ul><li>UNIQUE Constraint : Ensures that all values in a column are different. </li></ul><ul><li>CHECK Constraint : Makes sure that all values in a column satisfy certain criteria. </li></ul><ul><li>Primary Key Constraint : Used to uniquely identify a row in the table. </li></ul><ul><li>Foreign Key Constraint : Used to ensure referential integrity of the data. </li></ul>
    10. 10. Not Null <ul><li>For example, in the following statement, </li></ul><ul><li>CREATE TABLE Customer  (SID integer NOT NULL, Last_Name varchar (30) NOT NULL,  First_Name varchar(30)); </li></ul><ul><li>Columns &quot;SID&quot; and &quot;Last_Name&quot; cannot include NULL, while &quot;First_Name&quot; can include NULL. </li></ul><ul><li>An attempt to execute the following SQL statement, </li></ul><ul><li>INSERT INTO Customer (Last_Name, First_Name) values ('Wong','Ken'); </li></ul><ul><li>will result in an error because this will lead to column &quot;SID&quot; being NULL, which violates the NOT NULL constraint on that column. </li></ul>
    11. 11. Default For example, if we create a table as below: CREATE TABLE Student  (Student_ID integer Unique,  Last_Name varchar (30),  First_Name varchar (30),  Score DEFAULT 80); and execute the following SQL statement, INSERT INTO Student (Student_ID, Last_Name, First_Name) values ('10','Johnson','Rick'); The table will look like the following: Even though we didn't specify a value for the &quot;Score&quot; column in the INSERT INTO statement, it does get assigned the default value of 80 since we had already set 80 as the default value for this column. Student_ID Last_Name First_Name Score 10 Johnson Rick 80
    12. 12. Unique For example, in the following CREATE TABLE statement, CREATE TABLE Customer (SID integer Unique, Last_Name varchar (30),  First_Name varchar(30)); column &quot;SID&quot; has a unique constraint, and hence cannot include duplicate values. Such constraint does not hold for columns &quot;Last_Name&quot; and &quot;First_Name&quot;. So, if the table already contains the following rows: Executing the following SQL statement, INSERT INTO Customer values ('3','Lee','Grace'); will result in an error because '3' already exists in the SID column, thus trying to insert another row with that value violates the UNIQUE constraint. SID Last_Name First_Name 1 Johnson Stella 2 James Gina 3 Aaron Ralph
    13. 13. Check <ul><li>For example, in the following CREATE TABLE statement, </li></ul><ul><li>CREATE TABLE Customer (SID integer CHECK (SID > 0),  Last_Name varchar (30), First_Name varchar(30)); </li></ul><ul><li>Column &quot;SID&quot; has a constraint -- its value must only include integers greater than 0. So, attempting to execute the following statement, </li></ul><ul><li>INSERT INTO Customer values ('-3','Gonzales','Lynn'); </li></ul><ul><li>will result in an error because the values for SID must be greater than 0. </li></ul>
    14. 14. Primary Key A primary key is used to uniquely identify each row in a table. A primary key can consist of one or more fields on a table. When multiple fields are used as a primary key, they are called a composite key. CREATE TABLE Customer  (SID integer PRIMARY KEY,  Last_Name varchar(30),  First_Name varchar(30));
    15. 15. Foreign Key A foreign key is a field (or fields) that points to the primary key of another table. The purpose of the foreign key is, only values that are supposed to appear in the database are permitted. CREATE TABLE ORDERS  (Order_ID integer primary key, Order_Date datetime,  Customer_SID integer references CUSTOMER(SID),  Amount double); In the above example, the Customer_SID column in the ORDERS table is a foreign key pointing to the SID column in the CUSTOMER table.
    16. 16. <ul><li>Queries search the database, fetch info, and display it. This is done using the keyword </li></ul>Data Retrieval (Queries) SELECT SELECT * FROM publishers <ul><li>The * Operator asks for every column in the table. </li></ul>pub_id pub_name address state 0736 New Age Books 1 1 st Street MA 0987 Binnet & Hardley 2 2 nd Street DC 1120 Algodata Infosys 3 3 rd Street CA
    17. 17. <ul><li>Queries can be more specific with a few more lines </li></ul>Data Retrieval (Queries) <ul><li>Only publishers in CA are displayed </li></ul>SELECT * from publishers where state = ‘CA’ pub_id pub_name address state 0736 New Age Books 1 1 st Street MA 0987 Binnet & Hardley 2 2 nd Street DC 1120 Algodata Infosys 3 3 rd Street CA
    18. 18. <ul><li>Putting data into a table is accomplished using the keyword </li></ul>Data Input INSERT <ul><li>Table is updated with new information </li></ul>INSERT INTO publishers VALUES (‘0010’, ‘pragmatics’, ‘4 4 th Ln’, ‘chicago’, ‘il’) Keyword Variable pub_id pub_name address state 0736 New Age Books 1 1 st Street MA 0987 Binnet & Hardley 2 2 nd Street DC 1120 Algodata Infosys 3 3 rd Street CA pub_id pub_name address state 0010 Pragmatics 4 4 th Ln IL 0736 New Age Books 1 1 st Street MA 0987 Binnet & Hardley 2 2 nd Street DC 1120 Algodata Infosys 3 3 rd Street CA
    19. 19. <ul><li>User Tables: contain information that is the database management system </li></ul><ul><li>System Tables: contain the database description, kept up to date by DBMS itself </li></ul>Types of Tables There are two types of tables which make up a relational database in SQL pub_id pub_name address state 0010 Pragmatics 4 4 th Ln IL 0736 New Age Books 1 1 st Street MA 0987 Binnet & Hardley 2 2 nd Street DC 1120 Algodata Infosys 3 3 rd Street CA
    20. 20. Using SQL SQL statements can be embedded into a program (cgi or perl script, Visual Basic, C#, MS Access) OR SQL statements can be entered directly at the command prompt of the SQL software being used (such as mySQL)
    21. 21. Using SQL To begin, you must first CREATE a database using the following SQL statement: CREATE DATABASE database_name Depending on the version of SQL being used the following statement is needed to begin using the database: USE database_name
    22. 22. <ul><li>To create a table in the current database, use the CREATE TABLE keyword </li></ul>Using SQL CREATE TABLE authors (auth_id int(9) not null, auth_name char(40) not null) auth_id auth_name (9 digit int) (40 char string)
    23. 23. <ul><li>To insert data in the current table, use the keyword INSERT INTO </li></ul>Using SQL <ul><li>Then issue the statement </li></ul>SELECT * FROM authors INSERT INTO authors values(‘000000001’, ‘John Smith’) 000000001 John Smith auth_id auth_name
    24. 24. Using SQL SELECT auth_name, auth_city FROM publishers If you only want to display the author’s name and city from the following table: auth_id auth_name auth_city auth_state 123456789 Jane Doe Dearborn MI 000000001 John Smith Taylor MI auth_name auth_city Jane Doe Dearborn John Smith Taylor
    25. 25. Using SQL DELETE from authors WHERE auth_name=‘John Smith’ To delete data from a table, use the DELETE statement: auth_id auth_name auth_city auth_state 123456789 Jane Doe Dearborn MI 000000001 John Smith Taylor MI
    26. 26. Using SQL UPDATE authors SET auth_name=‘hello’ To Update information in a database use the UPDATE keyword Hello Hello Sets all auth_name fields to hello auth_id auth_name auth_city auth_state 123456789 Jane Doe Dearborn MI 000000001 John Smith Taylor MI
    27. 27. Using SQL ALTER TABLE authors ADD birth_date datetime null To change a table in a database use ALTER TABLE. ADD adds a characteristic. ADD puts a new column in the table called birth_date Type Initializer auth_id auth_name auth_city auth_state 123456789 Jane Doe Dearborn MI 000000001 John Smith Taylor MI birth_date . .
    28. 28. Using SQL ALTER TABLE authors DROP birth_date To delete a column or row, use the keyword DROP DROP removed the birth_date characteristic from the table auth_id auth_name auth_city auth_state 123456789 Jane Doe Dearborn MI 000000001 John Smith Taylor MI auth_state . .
    29. 29. Using SQL DROP DATABASE authors The DROP statement is also used to delete an entire database. DROP removed the database and returned the memory to system auth_id auth_name auth_city auth_state 123456789 Jane Doe Dearborn MI 000000001 John Smith Taylor MI
    30. 30. Normalization The process of removing redundant data by creating relations between tables is known as Normalization. Normalization process uses formal methods to design the database in interrelated tables.
    31. 31. Design DB
    32. 32. <ul><li>SQL is a versatile language that can integrate with numerous 4GL languages and applications </li></ul><ul><li>SQL simplifies data manipulation by reducing the amount of code required. </li></ul><ul><li>More reliable than creating a database using files with linked-list implementation </li></ul>Conclusion

    ×