Presentation is loading. Please wait.

Presentation is loading. Please wait.

Instructor Information: Mark Jamil

Similar presentations


Presentation on theme: "Instructor Information: Mark Jamil"— Presentation transcript:

1 Instructor Information: Mark Jamil questions@markjamil.com
ITS 180: Database Design Instructor Information: Mark Jamil

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

3 Assignment 1: OK solution
studenttID INT: Primary Key, Not Null, Unsigned, Auto-Increment firstName Varchar(255) lastName middleName streetAddress cityName zipCode INT phoneNumber dateOfBirth DATE ssn facultyID INT: Primary Key, Not Null, Unsigned, Auto-Increment firstName Varchar(255) lastName middleName streetAddress cityName zipCode INT phoneNumber dateOfBirth DATE ssn guardianID Foreign Key studenttID relationship Varchar(255) facultyID Foreign Key specializationID guardianID INT: Primary Key, Not Null, Unsigned, Auto-Increment firstName Varchar(255) lastName middleName streetAddress cityName zipCode INT phoneNumber dateOfBirth DATE ssn specializationID INT: Primary Key, Not Null, Unsigned, Auto-Increment specialization Varchar(255)

4 Assignment 1: Better Solution
roleID INT: Primary Key, Not Null, Unsigned, Auto-Increment roleName Varchar(255) roleDescription cityID INT: Primary Key, Not Null, Unsigned, Auto-Increment cityName Varchar(255) zipCode INT personID INT: Primary Key, Not Null, Unsigned, Auto-Increment firstName Varchar(255) lastName middleName streetAddress cityID Foreign Key phoneNumber INT dateOfBirth DATE ssn INT (unique key) roleID studenttID Foreign Key relationship Varchar(255) personID Foreign Key specializationID specializationID INT: Primary Key, Not Null, Unsigned, Auto-Increment specialization Varchar(255) Description Blob

5 Review: 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

6 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

7 Quiz 2 Name three possible table relationships in a database (aka cardinalization types)? In general, what is the difference between Char and Varchar? What is the difference between a Primary Key and a Foreign Key? What is a Master Table and why do we use them? What is a Transition (or Associative) Table and why do we use them?

8 Quiz 2: #6 What is the result of the following SQL command? (See table below) SELECT CustomerID, CustomerName  FROM Customers  WHERE Country = ‘USA’ OR Country = ‘Sweden’ ; CustomerID CustomerName Address City PostalCode Country 1 Alfreds Futterkiste Obere Str. 57 Berlin 12209 Germany 2 Ana Trujillo Avda. de la Constitución 2222 México D.F. 05021 Mexico 3 Marcus Smith Mataderos 2312 05023 USA 4 Michael Durant 120 Hanover Sq. London WA1 1DP UK 5 Jojo Snabbköp Berguvsvägen 8 Luleå S Sweden

9 Assignment 2: Journeyman Database
Update your university database from assignment #1 to include the following new data. For all people, we need to collect information about their gender, date of birth, and disabilities. Change the name of the “specialization” table to “departments” Departments offer courses Each course can be offered more than once per semester A course must have a teacher (faculty) A course may have many students A student can register for many courses At the end of each semester, the teacher must submit a grade for each student.

10 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

11 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 "Instructor Information: Mark Jamil"

Similar presentations


Ads by Google