1 / 21

CS122 Using Relational Databases and SQL Introduction to Relational Databases and MS Access

CS122 Using Relational Databases and SQL Introduction to Relational Databases and MS Access. Chengyu Sun California State University, Los Angeles. Overview. Introduction to databases Relational Model Using MS Access. Ubiquity of Databases.

Download Presentation

CS122 Using Relational Databases and SQL Introduction to Relational Databases and MS Access

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CS122 Using Relational Databases and SQLIntroduction to Relational Databases and MS Access Chengyu Sun California State University, Los Angeles

  2. Overview • Introduction to databases • Relational Model • Using MS Access

  3. Ubiquity of Databases • Anywhere where a large amount of information needs to be managed safely and efficiently • Web sites • Phone, cable, and gas companies • Schools • Hospitals • Government agencies • …

  4. Two notions of Database • Database software • Oracle, DB2, MS SQLServer, MySQL, PostgreSQL, MS Access • Collection of data • “create a database in Access”

  5. Database vs. File • More efficient search • ACID • Automicity • Consistency • Isolation • Durability

  6. Data Organization • Physical Model – how data is stored on disk • Logical Model – conceptual organization of data • Hierarchical • Network • Relational

  7. Hierarchical Model Company R&D Manufacture Sales Accounting Trust Accounting Corp Accounting Manager Employee 1 Employee 2 Employee 3 Name Phone Email

  8. Network Model Company R&D Manufacture Sales Accounting Trust Accounting Corp Accounting Manager Employee 1 Employee 2 Employee 3 Name Phone Email

  9. Relational Model • Proposed by Edgar F. Codd in earlier 1970’s • All major databases are relational

  10. Some Relational Database Terminology • Database • Table, relation • Attribute, field • Record, tuple, row • Column

  11. Attribute Type • Or field type, or data type • Determines the storage required for a field • Common attribute types • Text, Text(n) • Integer, Real • Currency, Date, Time • Image

  12. Schema • “Definition” of a database • Names of the tables • Attributes and attribute types in each table • Constraints on each tables • Dependencies between tables

  13. SQL • Standard query language of relational database • Supported by all relational databases (with minor variations) • Pronunciation

  14. Using MS Access

  15. Create a New Database • Blank Access database • File  New …  Database • Note: save the database to somewhere you can find

  16. Create a New Table • Select Tables in the Objects list • Create table in Design view • Save the table and give it a name • Click no when asked for a primary key EmployeeInfo <ID, Name, Title, Dept, Salary>

  17. View Table Information • View table design • View table data

  18. Input a Query • Select Queries in the Objects list • Click New then Design View • Close the Show Table window then select SQL View

  19. SQL Queries General form: select field_name(s) from table_name(s) where some_condition; Get all employee information: select * from EmployeeInfo; Get all employee names: select name from EmployeeInfo; Get the names of the employees whose salaries are higher than $55,000 select name from EmployeeInfo where salary > 55,000;

  20. A Few Notes about SQL • Command, field, and table names are case-insensitive • Number of white spaces does not matter • A string is enclosed between a pair of ’’ • String comparison using = is case-insensitive

  21. Exercise • Download student.mdb • Run following queries: • Find all student names • Find the names of the students whose major is MATH • Find the pre-requisites of COSC3380 • Save your queries as Query1, Query2, Query3

More Related