Databases - University Of Southern California

3y ago
15 Views
3 Downloads
725.26 KB
14 Pages
Last View : 1m ago
Last Download : 3m ago
Upload by : Kaleb Stephen
Transcription

DatabasesCSCI 201Principles of Software DevelopmentJeffrey Miller, Ph.D.jeffrey.miller@usc.edu

Outline Databases SQL Try It!USC CSCI 201L

Databases Database systems store data and provide a means of accessing,updating, manipulating, and analyzing data Databases are stored in files on a file system, but they are arrangedin a manner that allows for fast queries and updates A Database Management System (DBMS) is designed forprogrammers, not casual usersSQL-BasedMySQLPostgreSQLOracleMicrosoft SQL ServerIBM DB2NoSQLMongoDBFirebaseApache CouchDBApache CassandraUSC CSCI 201L3/14

Relational Databases Relational database management systems (RDBMS) provide three things› Structure – the representation of the data› Integrity – constraints on the data› Language – means for accessing and manipulating olowitzB-Tables are called relationsColumns are called attributesRows are called tuplesConnections are called relationshipsUSC CSCI 201L4/14

Relational tz111A4RajeshKoothrappali223A-332A433B543B-USC CSCI 201L5/14

Primary and Foreign Keys A primary key is a column (or a combination of multiple columns) in a table thatprovides a unique reference to a row in the table A foreign key is a link between two tables that uniquely identifies a row inanother tableClassStudentPrimary eign KeysGrades.classIDGrades.studentID6/14

Outline Databases SQL Try It!

SQL The Structured Query Language (SQL) is the primary languagesupported by DBMSs for accessing and manipulating data Some MySQL SQL statements you should know›››››››››SHOWCREATE DATABASEUSECREATE TABLEINSERTUPDATESELECTDELETEDROP If you are not familiar with SQL, there are many good tutorialsonline and our textbook has a good chapter reference as wellUSC CSCI 201L8/14

SQL Scripts After installing a DBMS, you will be able to run SQLscripts SQL scripts are files that contain a collection of SQLstatements that can be used for recreating databases andpopulating them with initial or testing data› This is often used in the testing phase of software engineeringto test different scenarios without requiring the QA engineersto insert all of the data manuallyUSC CSCI 201L9/14

Sample 72829DROP DATABASE IF EXISTS StudentGrades;CREATE DATABASE StudentGrades;USE StudentGrades;CREATE TABLE Student (studentID INT(11) PRIMARY KEY NOT NULL AUTO INCREMENT,fname VARCHAR(50) NOT NULL,lname VARCHAR(50) NOT NULL);INSERT INTO Student (fname, lname) VALUES ('Sheldon', 'Cooper');INSERT INTO Student (fname, lname) VALUES ('Leonard', 'Hofstadter');CREATE TABLE Class (ClassclassID INT(11) PRIMARY KEY NOT NULL AUTO INCREMENT,studentIDclassIDprefixnumprefix VARCHAR(5) NOT NULL,11CSCI103num INT(4) NOT NULL);22CSCI104INSERT INTO Class (prefix, num) VALUES ('CSCI', 103);INSERT INTO Class (prefix, num) VALUES ('CSCI', 104);CREATE TABLE Grade (GradegradeID INT(11) PRIMARY KEY NOT NULL AUTO INCREMENT,gradeIDclassIDstudentIDclassID INT(11) NOT NULL,111studentID INT(11) NOT NULL,221letterGrade VARCHAR(2) NOT NULL,FOREIGN KEY (classID) REFERENCES class(classID),312FOREIGN KEY (studentID) REFERENCES student(studentID)422);INSERT INTO Grade (studentID, classID, letterGrade) VALUES (1, 1, 'A');INSERT INTO Grade (studentID, classID, letterGrade) VALUES (1, 2, 'A');INSERT INTO Grade (studentID, classID, letterGrade) VALUES (2, 1, 'A');INSERT INTO Grade (studentID, classID, letterGrade) VALUES (2, 2, dterletterGradeAAABUSC CSCI 201L10/14

SQL Visualization Tools A visualization tool connects to a database and allowsexecution of SQL statements› The tool then will graphically display the results Free MySQL Clients››››Command line client (Windows, Mac, Linux)MySQL Workbench (Windows, Mac, Linux)Sequel Pro (Mac)Toad for MySQL (Windows)USC CSCI 201L11/14

Executing SQL There are a few ways to execute SQL statements, whichtypically depend on the DBMS We often want to be able to access databases from withinprograms though› This can be to insert, update, delete, or query the data The Java Database Connectivity (JDBC) drivers allow us toembed SQL in our Java code and execute those statements ona database programmaticallyUSC CSCI 201L12/14

Outline Databases SQL Try it!USC CSCI 201L

SQL Write SQL code to create the following A223A-332A433B553B-USC CSCI 201L14/14

Databases Database systems store data and provide a means of accessing, updating, manipulating, and analyzing data Databases are stored in files on a file system, but they are arranged in a manner that allows for fast queries and updates A Database Management System (DBMS) is designed for programmers, not casual users. USC CSCI 201L. 3/14. MySQL

Related Documents:

14 databases History 183 databases ProQuest Primary Sources available for: Introduction ProQuest Historical Primary Sources Support Research, Teaching and Learning. Faculty and students are using a variety of resources in research, teaching and learning – including primary sources,

Control Techniques, Database Recovery Techniques, Object and Object-Relational Databases; Database Security and Authorization. Enhanced Data Models: Temporal Database Concepts, Multimedia Databases, Deductive Databases, XML and Internet Databases; Mobile Databases, Geographic Information Systems, Genome Data Management, Distributed Databases .

1. Why is your church seeking affiliation with California Southern Baptist Convention and the San Diego Southern Baptist Association? 2. Included in this packet is a copy of Southern Baptists' doctrinal statement, "The Bap-tist Faith and Message" (see pages 7-16). This is not a creed, but it reflects common beliefs held by Southern Baptists.

Distributed databases allow more concurrent database requests than single-server databases. Gianluca Quercini Introduction to Databases Master DSBA 2020 { 20219/58. . 14 Administration 300,000 25 Education 150,000 62 Finance 600,000 45 Human Resources 150,000 Department B C codeD nameD budget

Examples. 6.2 Primary sequence databases 6.2.1 Introduction In the early 1980’s, several primary database projects evolved in different parts of the world (see table 6.1). There are two main classes of databases:DNA (nucleotide) databases and protein databases. The primary sequence d

1. A paradigm shift from the traditional data model. SQL databases enforce a strict schema, whereas NoSQL databases has a week notion of schema. At the core all NoSQL databases are key/value systems, the difference is whether the database understands the value or not. Different type of NoSQL databases have different properties. We'll see four major

Aldridge, Kristen Alabama Troy Columbus State Alabama University of Alabama Alsobrook, Andrew Auburn Auburn University Alverson, Davis Auburn Samford . UAB Johns Hopkins University Austin, Riley Southern Union Southern Union Southern Union Austin, Ryan Southern Union Southern Union Southern Union Baeder, Julie LSU Clemson

Types of NoSQL Databases Document Databases [MongoDB, CouchDB] Column Databases [Apache Cassandra] Key-Value Stores [Redis, Couchbase Server] Cache Systems [Redis, Memcached] Graph Databases [Neo4J] Streaming Systems [FlinkDB, Storm] 7. Document Database 8. Document Data Model