Presentation is loading. Please wait.

Presentation is loading. Please wait.

BUS 602: Quantitative Methods in Business

Similar presentations


Presentation on theme: "BUS 602: Quantitative Methods in Business"— Presentation transcript:

1 BUS 602: Quantitative Methods in Business
Instructor Information: Mark Jamil Website:

2 About this course This is not a pure programming course… per se. You will not be graded on your knowledge of programming but rather on your ability to logically use SQL to query data. Functional code is important to help facilitate your learning however in most cases I will accept pseudo-code and non-working code as long as you demonstrate that you understood the concept. This is not a writing class. You will not be graded on spelling, punctuation, or grammar but you will be graded on the content of your answers. I prefer teaching Quantitative Methods as a practical lab course. Rather than lecture the entire 4 hours, most of the course time will be spent solving practical problems in a lab style environment. During lab you will be able to ask questions, work together to solve problems, and learn at your own pace.

3 Goals The goals of this course include:
Learn how data is logically stored in modern day databases Learn how to retrieve data from a database using SQL Learn how to use the data to build meaningful statistics Learn how to evaluate data using various analytical methods such as regression testing, and linear analysis Learn how to make business decisions using quantitative data

4 Grading Information POSSIBLE EXTRA CREDIT
Attendance (10 points possible) Class participation (10 points possible) Quizzes (20 points possible) Assignments (40 points possible) Final Project (20 points possible) 100 Points Possible Points Grade | Points Grade A+ | C A | D A- | 59 or less F B+ | B | B- | POSSIBLE EXTRA CREDIT 5 Extra Credit Points - Perfect Attendance

5 EXTRA CREDIT Perfect Attendance (5 Points Extra Credit)
Must be present at all class meetings Cannot be more than 15 minutes late to class

6 Hints for Getting an “A”
Attendance is important Points just for being in class! (10 points) Course is structured around discussions (10 points) Quiz questions are taken directly from discussion (20 points) Perfect Attendance Bonus (5 points) 45 points can easily be earned by simply attending class! Most assignment can be completed in class (40 points)

7 In the Beginning… Data was written into stone tablets.
Then we had paper. Then we had a lot of paper bound together into books. Then we started organizing books: Page numbering. We separated books into chapters. Chapters were listed in an index. Books were taking up too much space so we started looking for ways to shrink them… anyone remember the microfiche? Then we created integrated circuits allowing us to store a lot of data on electronic parts. Time for a game…

8 Early Electronic Data Storage
This is how data was stored initially. This is inefficient because every time we wanted to search for a piece of data, we had to transverse all the data until we found what we are looking for. For example, how many sentences are in this paragraph? You would need to read the entire paragraph and search for end of sentence punctuations to figure out that there are four sentences. Or are there only three? Maybe there are five but the point is that this is very time consuming and even a computer can be brought to its knees if there is a very large set of data to transverse. Okay lets call it seven sentences. Really I am not kidding this time…

9 Enter Big Data Initially, electronics were so fast at storing and looking up data, people did not worry about performance issues. Once the amount of data grew, it became obvious that we needed to find a better way to organize the data. Enter IBM. To meet the need for big data companies started creating commercial database systems. The 1st IBM database was called IMS and was sold to the government for the Apollo space program in the 1960’s. The 1st commercially success database was Saber, and was purchased by American Airlines, also in the 1960’s. IMS and Saber were hierarchical databases. IBM researcher (Ed Cobb) theorizes the relational database. IBM switched all their data products to the relational model in the 70s (System R) and continued their virtual monopoly on business computing well into the 80s. System R was the 1st database to use a query language called “Sequel.” “Sequel” was later changed to “SQL” due to copyright issues with the name “Sequel.”

10 What happened next? Due to the high cost of IBM hardware/software, students at UC Berkeley made their own relational database for educational use in the early 70s. It was called Ingres. Ingress was the 1st open source relational database. It used a scripting language called QUEL . Database systems that used Ingress source code include: MS SQL, Sybase, & Posgres. Knowing IBM was costly and that UC Berkeley did not have money to market their database; Larry Ellison decided to make his own relational database backed by investors. It was called Oracle. Oracle took market share from Ingress mostly due to huge marketing campaigns. Oracle used SQL. Lets play another game…

11 Better Data Storage This is inefficient because every time we wanted to search for a piece of data, we had to transverse all the data until we found what we are looking for. For example, how many sentences are in this paragraph? You would need to read the entire paragraph and search for end of sentence punctuations to figure out that there are four sentences. Or are there only three? Maybe there are five but the point is that this is very time consuming and even a computer can be brought to its knees if there is a very large set of data to transverse. Okay lets call it seven sentences. Really I am not kidding this time.

12 Definitions SQL (pronounced S-Q-L or sequel) Database Table Record
Structured Query Language. Is a computer language used to communicate with most modern database systems. Database Is an organized collection of data used to provide information. Table A data storage method using rows and columns. In computer science, rows are also referred to as “Records” and columns are referred to as “Fields.” Record Is a row in the database. Field Is a column in the database.

13 Definitions Primary Key Foreign Key Index
Is a field (or column) that contains unique data within a table. Because the data is the column is unique, every row (or record) becomes unique. A table may have multiple keys or no keys at all. If you have more than one key in a table, it is called a composite key. For our purposes, keys are required to form relations. Foreign Key Is a relation formed between two tables where one table utilizes a primary key from the other related table, as part of its data. Foreign Keys are NOT necessarily unique. Foreign Keys provide integrity because they MUST match a Primary Key in the related table. Index Can be applied to columns or rows. Indices are NOT Keys!!!! They create a pointer to a record or field for faster database lookup. Typically copy data thus requiring extra memory.

14 Relationships (aka Cardinality)
One-to-One Each row in one table, corresponds to exactly one row in another table. One-to-Many Each row on one table can correspond to many rows in another table. Many-to-Many Every row may have one or more associated rows in another related table.

15 Simple Entity Relation (ER) Diagram

16 Computer Memory Current computers store memory in units called bits.
Bits are represented by 0 and 1 What does 32 bit mean? A computer that has a 32 bit CPU can process 32 bits (32 zero’s or one’s) in a single cycle (measured in hertz or 1/s). What is a byte? A byte is 8 bits such as or

17 Beware of the difference in Bit and Byte
Historically computer memory is labeled in bytes. 512 kiloBYTEs Cache 128 megaBYTEs of RAM 4 teraBYTE Hard Drive 1 petaBYTE = 1000 teraBYTEs 1 exaBYTE = 1000 petaBYTEs Internet Service Providers use bits instead of bytes. 2 MB service means 2 megaBITs not bytes!! 2 Mbits service means 250 Kbytes per second. Question: How long would it take to fill a 10 Mbyte hard drive with data streaming from a 10 Mbit internet connection?

18 How do we store data in bits?
How do I store the number 5 in Binary? You need 3 bits of storage 0 0 0 = 0 = 1 0 1 0 = 2 0 1 1 = 3 1 0 0 = 4 1 0 1 = 5 1 1 0 = 6 1 1 1 = 7 What happens if someone wants to store larger numbers? Or even words? The relationship between bits and how many permutations it can have is 2n. Thus if you want to store the number 128, you need at least 7 bits of storage space (27 = 128) How are letters stored? Letters are encoded. There are many different encoding systems such as ASCII or UTF-8 ASCII stores everything in 8 bits of data (aka hex) “A” is equivalent to “65” or “a” is equivalent to “97” or “1” is equivalent to “1” or Null is equivalent to “0” or

19 Data Types Databases generally store human readable data be it a number or some text Common data types (sizes are not always the same!) Data Type Size Limit How it is stored INT 4 bytes Fixed Can store value of + or - 2 billion. Or unsigned up to 4 billion DATETIME 8 bytes Fixed BOOLEAN 1 byte Fixed CHAR bytes Fixed VARCHAR bytes Variable Always adds 1 extra byte for storing its own length BLOB 0-65k bytes Variable Since it stores twice as much as Varchar, it needs 2 bytes of storage for length

20 Table Example MovieName MovieGenre MovieYear Star Wars
Drama, Action, Science Fiction 1977 Gladiator Drama 1992 Ju-On Horror 2001 Action 1955 The Matrix Action, Sience Fiction 2003 2000 Hercules 2013

21 Unique Records (Unique Keys)
MovieID MovieName MovieGenre MovieYear 1 Star Wars Action, Drama, Science Fiction 1977 2 Gladiator Drama 1992 3 Ju-On Horror 2001 4 Action 1955 5 The Matrix Action, Sience Fiction 2003 6 2000 7 Hercules 2013 8

22 Data Integrity (Incorrect Data Entry)
MovieID MovieName MovieGenre MovieYear 1 Star Wars Action, Drama, Science Fiction 1977 2 Gladiator Drama 1992 3 Ju-On Horror 2001 4 Action 1955 5 The Matrix Action, Sience Fiction 2003 6 2000 7 Hercules 2013 8

23 Better Integrity 1977 1992 2001 Transition Table 1955 2003 2000 2013
MovieID GenreID 1 2 5 3 4 6 7 8 Transition Table MovieID MovieName MovieYear 1 Star Wars 1977 2 Gladiator 1992 3 Ju-On 2001 4 1955 5 The Matrix 2003 6 2000 7 Hercules 2013 8 GenreID Genre 1 Action 2 Drama 3 Comedy 4 Horror 5 Science Fiction Master Table

24 Real ER Diagram Here is the ER diagram for a fairly small application known as Drupal.

25 Setting up your VM Install VirtualBox Create a guest machine
Install Debian (we are using version 8) Do not install the user interface options Edit repository list at /etc/apt/sources.list Add the following servers to the list: deb jessie main contrib non-free deb-src jessie main contrib non-free Comment out the cdrom and the other servers Remember to do an apt-get update and apt-get upgrade Install MySQL apt-get install mysql-server Configure MySQL and users to allow remote access Edit /etc/mysql/my.cnf Change the Bind-Address FROM TO

26 Setting up a remote MySQL user
Log into mysql by typing mysql –u username –p Inside of the mysql shell add a new user using the following command: CREATE USER IDENTIFIED BY ‘password’; GRANT ALL ON *.* TO Remember to restart the service by typing service mysql restart Install MySQL Workbench on you actual computer and connect to your SQL server. You will need the VM ip address. Your server IP address can be found by typing: ifconfig

27 Intro to SQL Structured Query Language
SQL is a scripting language designed specifically for database server. You can type SQL commands inside the MySQL shell or inside the MySQL Workbench query tool. ER diagrams can be translated to SQL commands by exporting them inside MySQL workbench. The 4 most frequently used SQL commands are variations of: Select – used to look up data in the database Insert – inserts new records (or rows) into the database Update – used to change the values inside a record (or row) Delete – removes values from a record (or row) and can be used to completely delete a record

28 Intro to SQL continued To access data in more than one table, you sometimes need to write more than one SQL command. You can embed one SQL command into another. Some people call statements like this “nested statements” while others call them “subqueries.” For instance, you can retrieve a bunch of user ID’s from one table and use the resultant ID’s to look up specific data for those ID’s in another table. Example: SELECT salary FROM wages WHERE userID = ( SELECT userID FROM employees WHERE status = ‘current‘ )


Download ppt "BUS 602: Quantitative Methods in Business"

Similar presentations


Ads by Google