Your SlideShare is downloading. ×
0
Database Application for La Salle
Database Application for La Salle
Database Application for La Salle
Database Application for La Salle
Database Application for La Salle
Database Application for La Salle
Database Application for La Salle
Database Application for La Salle
Database Application for La Salle
Database Application for La Salle
Database Application for La Salle
Database Application for La Salle
Database Application for La Salle
Database Application for La Salle
Database Application for La Salle
Database Application for La Salle
Database Application for La Salle
Database Application for La Salle
Database Application for La Salle
Database Application for La Salle
Database Application for La Salle
Database Application for La Salle
Database Application for La Salle
Database Application for La Salle
Database Application for La Salle
Database Application for La Salle
Database Application for La Salle
Database Application for La Salle
Database Application for La Salle
Database Application for La Salle
Database Application for La Salle
Database Application for La Salle
Database Application for La Salle
Database Application for La Salle
Database Application for La Salle
Database Application for La Salle
Database Application for La Salle
Database Application for La Salle
Database Application for La Salle
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Database Application for La Salle

183

Published on

Database Application for La Salle

Database Application for La Salle

Published in: Technology, Economy & Finance
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

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

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide
  • Transcript

    • 1. Database Application in daily LaSalle Financial Reporting Jimmy Chu 2009-02-27
    • 2. Overview <ul><li>Purpose of the Seminar </li></ul><ul><li>3 Sections (Excel vs DB) </li></ul><ul><ul><li>General Comparison </li></ul></ul><ul><ul><li>Basic Operations </li></ul></ul><ul><ul><li>Further explanation in SELECT and CREATE </li></ul></ul>
    • 3. Who am I? <ul><li>Entrepreneur </li></ul><ul><li>Software Developer </li></ul><ul><li>Financial Background (and VBA too) </li></ul><ul><li>My highschool is La Salle also </li></ul>
    • 4. A Basic Survey <ul><li>How familiar are you with: </li></ul><ul><ul><li>Excel? </li></ul></ul><ul><ul><li>Database? </li></ul></ul><ul><li>What do you do daily with: </li></ul><ul><ul><li>Excel? </li></ul></ul><ul><ul><li>Database? </li></ul></ul>
    • 5. 1. General Comparison
    • 6. Look & Feel - 1 <ul><li>Look & Feel: </li></ul>
    • 7. Look & Feel - 2
    • 8. Look & Feel - 3 <ul><li>DB – No looks? Many looks? </li></ul>
    • 9. Similarity of Excel vs. DB <ul><li>Store Data </li></ul><ul><ul><li>Excel – in rows and columns </li></ul></ul><ul><ul><li>DB – in records and fields </li></ul></ul><ul><li>Manipulate Data </li></ul><ul><li>Advanced </li></ul><ul><ul><li>VBA Macro </li></ul></ul><ul><ul><li>SQL language </li></ul></ul>
    • 10. What Excel is good at? <ul><li>Simpler to Use – WYSIWYG </li></ul><ul><li>Good at Data Analysis </li></ul><ul><ul><li>Charting </li></ul></ul><ul><ul><li>Easy at filtering </li></ul></ul><ul><ul><li>Pivot Table </li></ul></ul><ul><li>Presentation (a big thing) </li></ul><ul><ul><li>“ If you are relying more and more on Excel, your career is on the right track.” </li></ul></ul>
    • 11. What DB is good at – 1/2 <ul><li>Storing vast amount of Records </li></ul><ul><ul><li>Unlimited (in theory) vs. Excel </li></ul></ul><ul><ul><ul><li>65,536 rows, 256 columns, 32,000 chars </li></ul></ul></ul><ul><li>When data structure need to changed from time to time </li></ul><ul><ul><li>Excel: Referenced by row and column </li></ul></ul><ul><ul><li>DB: Referenced by ID </li></ul></ul>
    • 12. What DB is good at – 2/2 <ul><li>Optimized actions for create, read, update, delete operation (CRUD) </li></ul><ul><li>Database for external connection </li></ul><ul><li>Transaction (COMMIT/ROLLBACK) </li></ul>
    • 13. 2. Basic Operations
    • 14. Create a Table – Excel
    • 15. Create a Table – DB 1 <ul><ul><li>CREATE TABLE lasalle.stocks( </li></ul></ul><ul><ul><li>S_ID INT (11) NOT NULL AUTO_INCREMENT, </li></ul></ul><ul><ul><li>ticker VARCHAR (50) NOT NULL, </li></ul></ul><ul><ul><li>name VARCHAR (50) DEFAULT NULL, </li></ul></ul><ul><ul><li>country VARCHAR (20) DEFAULT NULL, </li></ul></ul><ul><ul><li>description VARCHAR (128) DEFAULT NULL, </li></ul></ul><ul><ul><li>PRIMARY KEY (S_ID), </li></ul></ul><ul><ul><li>UNIQUE INDEX ticker USING BTREE (ticker), </li></ul></ul><ul><ul><li>UNIQUE INDEX name USING BTREE (name) </li></ul></ul><ul><ul><li>) </li></ul></ul><ul><ul><li>ENGINE = INNODB </li></ul></ul><ul><ul><li>AUTO_INCREMENT = 21 </li></ul></ul><ul><ul><li>CHARACTER SET utf8 </li></ul></ul><ul><ul><li>COLLATE utf8_general_ci; </li></ul></ul>
    • 16. Create a Table – DB 2
    • 17. Insert an Entry - Excel
    • 18. Insert an Entry – DB 1 <ul><li>INSERT INTO stocks (`S_ID`, `ticker`, `name`) VALUES </li></ul><ul><li>(1,&quot;000002 CH Equity&quot;,&quot;China Vanke Co Ltd -A&quot;), </li></ul><ul><li>(2,&quot;000024 CH Equity&quot;,&quot;China Merchants Property Dev&quot;), </li></ul><ul><li>(3,&quot;034830 KS Equity&quot;,&quot;Korea Real Estate Invest&quot;), </li></ul><ul><li>(4,&quot;073530 KS Equity&quot;,&quot;Kocref Cr-Reit 3&quot;) … </li></ul>
    • 19. Insert an Entry – DB 2
    • 20. Update an Entry - DB <ul><li>UPDATE stocks SET name = ‘Malaysia ABC’ where S_ID = 2 </li></ul>
    • 21. View the Entries - Excel <ul><li>All the stock contains ‘HK Equity’ </li></ul>
    • 22. View the Entries - Excel
    • 23. View the Entries - DB <ul><li>select * from stocks where ticker like ‘%HK Equity%’ limit 10; </li></ul>
    • 24. Bonus
    • 25. 3. CREATE and SELECTS
    • 26. About SELECT <ul><li>select * from stocks where ticker like ‘%HK Equity%’ limit 10; </li></ul><ul><li>General syntax: </li></ul><ul><li>Select columns from tables where conditions </li></ul>
    • 27. About SELECT <ul><li>Select columns from tables where conditions </li></ul><ul><li>WHERE condition could be another SELECT statement </li></ul>
    • 28. About SELECT <ul><li>select * from acct_constituents where </li></ul><ul><li>weight >0 </li></ul><ul><li>and S_ID in (select S_ID from stocks where ticker like '%HK Equity%'); </li></ul><ul><li>Conclusion: You can formulate complex conditions </li></ul>
    • 29. SELECT – Indexing 1 <ul><ul><li>CREATE TABLE lasalle.stocks( </li></ul></ul><ul><ul><li>… </li></ul></ul><ul><ul><li>PRIMARY KEY (S_ID), </li></ul></ul><ul><ul><li>UNIQUE INDEX ticker USING BTREE (ticker), </li></ul></ul><ul><ul><li>UNIQUE INDEX name USING BTREE (name) </li></ul></ul><ul><ul><li>) </li></ul></ul>
    • 30. SELECT – Indexing 2 <ul><li>Index? No Index? </li></ul><ul><ul><li>Space/Time Constraint </li></ul></ul><ul><li>What fields to index? </li></ul><ul><ul><li>The fields always happened in the WHERE conditions. </li></ul></ul>
    • 31. SELECT – Indexing 3 <ul><li>Specifying Index </li></ul><ul><ul><li>PRIMARY KEY </li></ul></ul><ul><ul><li>UNIQUE </li></ul></ul><ul><ul><li>INDEX </li></ul></ul><ul><li>“ MySQL can quickly determine the position to seek to in the middle of the data file without having to look at all the data. If a table has 1,000 rows, this is at least 100 times faster than reading sequentially. ” </li></ul>
    • 32. SELECT – JOIN 1 <ul><li>Select columns from tables where conditions </li></ul><ul><li>2 tables: </li></ul><ul><ul><li>Table A Table B </li></ul></ul>
    • 33. SELECT – JOIN 2
    • 34. SELECT – JOIN 3
    • 35. Architecture - 1 <ul><li>Database Architecture: </li></ul><ul><ul><li>First Normal Form </li></ul></ul><ul><ul><li>Second Normal Form </li></ul></ul><ul><ul><li>Third Normal Form </li></ul></ul><ul><li>Forget about it! </li></ul>
    • 36. DB Architecture - 2 <ul><li>Store only 1 information in one field </li></ul><ul><ul><li>Example: ticker, name </li></ul></ul><ul><ul><li>Example: firstname, lastname </li></ul></ul><ul><li>Avoid Data Duplication </li></ul><ul><ul><li>Harder to maintain </li></ul></ul><ul><ul><li>Data inconsistency </li></ul></ul><ul><ul><li>When to break this rule? </li></ul></ul>
    • 37. DB Architecture - 3 <ul><li>Relationship </li></ul><ul><ul><li>One-to-One </li></ul></ul><ul><ul><li>One-to-Many </li></ul></ul><ul><ul><li>Many-to-Many </li></ul></ul>
    • 38. DB Architecture - 4 <ul><li>Identify your PRIMARY key </li></ul><ul><ul><li>Could be more than 1 field </li></ul></ul><ul><li>Identify your FOREIGN key </li></ul><ul><ul><li>You don’t want to have nightmare in updating the table </li></ul></ul><ul><li>Know which column to index </li></ul>
    • 39. Q & A Thanks for attending the Seminar

    ×