mysql q1

  1. What software is needed to use a database.
    • client software
    • server software
    • SQL interface
  2. What components are needed to use a database?
    • user<->Database Application<->Database Management System(DBMS)<->Database
    • Image Upload 2
  3. DBMS
    Database Management System
  4. Desktop database systems typically:
    • 1) Have only a few tables
    • 2) Are simple in design
    • 3) Involve only a few computers
    • 4) Support only a few users
    • 5) MS-Access bundles the RDBMS and Application components together
  5. Name some organizational database systems.
    • IBM DB2
    • Oracle
  6. Organizational database systems typically:
    • 1) Support several users simultaneously
    • 2) Include more than one application
    • 3) Involve multiple computers
    • 4) Are complex in design
    • 5) Have many tables
    • 6) Have many databases
  7. picture Organizational Database System
    Image Upload 4
  8. SQL
    • Structured Query Language
    • It is the standard language used for retrieval and manipulation of data from a relational database.
  9. An SQL query...
    An SQL query or simply query is a programming statement. It is the method by which you retrieve and update information. Instead of pointing and clicking to add record, you issue an SQL Insert statement.
  10. MySQL Workbench is a(n)...
    editing environment.
  11. MySQL is...
    MySQL is a RDBMS that uses the SQL language. It is very popular for web applications. It is open source, scalable. It can handle 2 – 16 terabytes of data
  12. SQL DML statements
    • DML= Data Manipulation Language
    • SELECT
    • INSERT
    • UPDATE
    • DELETE
  13. SQL DDL statements
    • DDL =Data Definition Language
    • CREATE DATABASE, TABLE
    • DROP DATABASE, TABLE
  14. Programming Standards for Script Files
    • 1.Capitalize all keywords – SELECT, not select
    • 2.Use camel case for names -- hourlyPay, custID
    • 3.Start each clause on a new line
    • 4.Break long clauses into multiple lines
    • 5.Indent continued lines
    • 6.Place your name and a description of the script at the top of the file
    • 7.Further comments are only required for code that is difficult to understand or where requested
    • 8.Where possible, use part of table name in column name e.g. customer table column names: custID, custFName
  15. SQL Commenting
    • Block comment (more than one line)
    • /*  
    • stuff 
    • more stuff
    • */
    • Single line comment
    • -- This is a comment.  A space is required after the 2 hyphens.

    MySQL is NOT case sensitive. It ignores white space and every statement ends with a semicolon   ;
  16. row and columns
    records and fields
  17. 1:M
    • one-to-many
    • primary key and foreign key
    • one vendor may have many invoices
    • PK in vendor table
    • FK in invoices table(same value for same vendor)
  18. EER
    Enhanced Entity Relationship (EER) Diagram.

    • A primary key is marked with a key icon.
    • A dark diamond shows a foreign key.
  19. The six basic steps for designing a data structure
    • 1:Identify the data elements
    • 2:Subdivide each element into its smallest useful components
    • 3:Identify the tables and assign columns
    • 4:Identify the primary and foreign keys
    • 5:Review whether the data structure is normalized
    • 6:Identify the indexes
  20. A persons name has components.
    The first name and last name are different components.
  21. 1NF
    First (1NF) The value stored at the intersection of each row and column must be a scalar value, and a table must not contain any repeating columns.
  22. The benefits of normalization
    • More tables, and each table has an index on its primary key. That makes data retrieval more efficient.
    • Each table contains information about a single entity. That makes data retrieval and insert, update, and delete operations more efficient.
    • Each table has fewer indexes, which makes insert, update, and delete operations more efficient.
    • Data redundancy is minimized, which simplifies maintenance and reduces storage
  23. 2NF
    Second (2NF)  Every non-key column must depend on the entire primary key.
  24. 3NF
    Third (3NF) Every non-key column must depend only on the primary key.
  25. A table is in first normal form (1NF) when:
    • A table is in first normal form (1NF) when:
    • 1.each column has a unique name
    • 2.the order of rows and columns doesn’t matter
    • 3.each column has a single data type
    • 4.no two rows contain identical values
    • 5.each column contains a single value
    • 6.columns do not contain repeating groups
  26. How to create AP database?
    • -- create the database
    • DROP DATABASE IF EXISTS ap;
    • CREATE DATABASE ap;
  27. How do you select the AP database?
    • -- select the database
    • USE ap;
  28. How do you create table with fields?
    • create table animal
    • (
    •    anID    INT    primary key,
    •    anName    varchar(15),
    •    anWeightkg    decimal(6,1),
    •    anDOB date,
    •    anPurchPrice    decimal(7,2),
    •    anType    char(10),
    •    constraint animalType_fk_animal
    •       foreign key (anType)
    •       references animalType (atType)
    • );
  29. In Workbench, where can you see the databases and tables that are created?
    In the SCHEMAS in the Navigator(must be refreshed) on the left.
  30. What is a schema?
    In mysql, another name for a database.
  31. How can you examine the tables?
    right click the table name and pick Select Row...
  32. How do you create the database from the script file?
    • 1) from file pick Open SQL Script.
    • 2) click lightning bolt execution icon.
  33. Is File, Run SQL Script the same as the lightning bolt icon?
  34. How do you view or change a table design?
    • Right click on table name and choose Alter Table.
    • Field names, datatypes, and other properties are listed below.
  35. How do you view a tables: field name, datatype and other properties?
    Right click on table name and choose Alter Table.
  36. How do you create a simple query?
    • 1) from File, New Query Tab
    • 2) type SELECT * FROM tableName;(make sure the proper table is bold in the Navigator)
    • Or
    • SELECT *
    • FROM database.tableName
    • 3) Run
  37. How do you insert into a table?
    • insert into animalType values
    • ('Capybara',2,'fruit'),
    • ('Snake',25,'mice'),
    • ('Ferret',10,'pellets'),
    • ('Elephant',50,'hay');
  38. How do you display all orders in the om database sorted by customer_id?
    • SELECT *
    • FROM om.orders
    • ORDER BY customer_id;
Author
slc53
ID
321014
Card Set
mysql q1
Description
mysql q1
Updated