1 / 20

Databases and Data Representation

Databases and Data Representation. Databases and Data Representation. Database Management System (DBMS) Provides efficient , convenient , and safe multi-user storage of and access to massive amounts of persistent data Provides a programming interface that allows a user or program to

Download Presentation

Databases and Data Representation

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. Databases and Data Representation CS360 Windows Programming

  2. Databases and Data Representation • Database Management System (DBMS) • Provides efficient, convenient, and safe multi-user storage of and access to massive amounts of persistent data • Provides a programming interface that allows a user or program to • - Create new databases and specify their structure • - Query and modify the data • Early DBMSs were ad hoc, with no two the same • Now one approach predominates: relational databases and SQL (Structured Query Language) CS360 Windows Programming

  3. Databases • A "relation" is a table of data CS360 Windows Programming

  4. Databases • The columns are known as "attributes" Students LectID Name Course CS360 Windows Programming

  5. Databases • The rows are called "tuples" Students LectID Name Course CS360 Windows Programming

  6. Databases • It is allowable for some values to be missing Students LectID Name Course CS360 Windows Programming

  7. Databases • We can add, remove, or update tuples Students LectID Name Course CS360 Windows Programming

  8. Databases • Each attribute has an underlying domain, or data type Students LectID Name Course int string string int CS360 Windows Programming

  9. Databases • The structure of the table is referred to as its schema • Lecturers(LectID, Name, Course, Students) LectID Name Course Students CS360 Windows Programming

  10. Primary Key • Every table must have a primary key • No two tuples can have the same LectID • LectID cannot be null LectID Name Course Students CS360 Windows Programming

  11. Tables • Suppose that we want to add data about lecturers offices LectID Name Course Students CS360 Windows Programming

  12. Tables • But suppose that lecturers can have more than one office. • We can’t add additional rows for the same lecturers without violating the primary key constraint, so we use another table. LectID Name Course Students Building Room CS360 Windows Programming

  13. Multiple Tables • Solution: Add a new table LectID Name Course Students Building Room CS360 Windows Programming

  14. Relationships • Better to store LectID LectID Name Course Students LectID Building Room CS360 Windows Programming

  15. Relationships • Better to store LectID LectID Name Course Students LectID Building Room Primary key Foreign key CS360 Windows Programming

  16. SQL Queries • SELECT returns tuples that satisfy some condition • SELECT Name, Course FROM Lecturers WHERE Students > 15 LectID Name Course Students Name Course CS360 Windows Programming

  17. SQL Queries • SELECT * • FROM Lecturers • WHERE Students > 15 Attributes Relations Tuples CS360 Windows Programming

  18. SQL Queries • SELECT * • FROM Lecturers • WHERE Students > 15 • OR Name = ‘Shereen’ CS360 Windows Programming

  19. SQL Queries • Wildcards: • % matches any number of characters • _ matches any single character • [] matches any single character in set or range • [^] matches any single character not in set or range CS360 Windows Programming

  20. Database Management Systems • Many examples of DBMSs • Oracle • SQL Server • MySQL • http://dev.mysql.com/ CS360 Windows Programming

More Related