Rob Gleasure robgleasure.com

Slides:



Advertisements
Similar presentations
Query Methods (SQL). What is SQL A programming language for databases. SQL (structured Query Language) It allows you add, edit, delete and run queries.
Advertisements

Physical Database Design Data Migration/Conversion.
Cs3431 Constraints Sections 6.1 – 6.5. cs3431 Example CREATE TABLE Student ( sNum int, sName varchar (20), prof int, CONSTRAINT pk PRIMARY KEY (snum),
Quick-and-dirty.  Commands end in a semi-colon ◦ If you forget, another prompt line shows up  Either continue the command or…  End it with a semi-colon.
SQL Data Definition II Stanislava Armstrong 1SQL Data Definition II.
Murali Mani SQL DDL and Oracle utilities. Murali Mani Datatypes in SQL INT (or) INTEGER FLOAT (or) REAL DECIMAL (n, m) CHAR (n) VARCHAR (n) DATE, TIME.
SQL Keys and Constraints Justin Maksim. Key Declaration Key constraint defined within the CREATE TABLE command Key can be declared using either the PRIMARY.
SQL DDL constraints Restrictions on the columns and tables 1SQL DDL Constraints.
Using Relational Databases and SQL Steven Emory Department of Computer Science California State University, Los Angeles Lecture 10: Data Definition Language.
Database Systems Lecture 5 Natasha Alechina
 SQL stands for Structured Query Language.  SQL lets you access and manipulate databases.  SQL is an ANSI (American National Standards Institute) standard.
Databases in Visual Studio. Database in VisualStudio An MS SQL database are built in Visual studio The Name can be something like ”(localdb)\Projects”
Constraints  Constraints are used to enforce rules at table level.  Constraints prevent the deletion of a table if there is dependencies.  The following.
Deanery of Business & Computer Sciences SQL Structured Query Language Implementation Lecture – 8 Database Technology Level I.
SQL Data Definition Language (DDL) Using Microsoft SQL Server 1SDL Data Definition Language (DDL)
Slide 1 Chapter 7 – Part 1 Data Definition Language & Data Manipulation Language.
Advanced Database Management System
SQL Basics. 5/27/2016Chapter 32 of 19 Naming SQL commands are NOT case sensitive SQL commands are NOT case sensitive But user identifier names ARE case.
SQL: DDL. SQL Statements DDL - data definition language –Defining and modifying data structures (metadata): database, tables, views, etc. DML - data manipulation.
Creating Tables and Inserting Records -- Not easy to edit! -- check constraints! Create table test1 ( C1 char(5) primary key, C2 Varchar2(15) not null.
Dec 8, 2003Murali Mani Constraints B term 2004: lecture 15.
1 SQL - II Data Constraints –Applying data constraints Types of data constraints –I/O constraints The PRIMARY KEY constraints The FOREIGN KEY constraints.
SQL Structured Query Language. Aims  To introduce the implementation of a Physical design using SQL.  To introduce SQL Data Definition Language (DDL).
1 DBS201: More on SQL Lecture 3. 2 Agenda How to use SQL to update table definitions How to update data in a table How to join tables together.
IS6146 Databases for Management Information Systems Lecture 3: SQL III – The DDL Rob Gleasure robgleasure.com.
SQL constrains and keys. SORTED RESULTS Sort the results by a specified criterion SELECT columns FROM tables WHERE predicates ORDER BY column ASC/DESC;
Table Structures and Indexing. The concept of indexing If you were asked to search for the name “Adam Wilbert” in a phonebook, you would go directly to.
SQL - Training Rajesh Charles. Agenda (Complete Course) Introduction Testing Methodologies Manual Testing Practical Workshop Automation Testing Practical.
Rob Gleasure robgleasure.com
Rob Gleasure robgleasure.com
Rob Gleasure robgleasure.com
SQL: Schema Definition and Constraints Chapter 6 week 6
Insert, Update and the rest…
Prepared by : Moshira M. Ali CS490 Coordinator Arab Open University
SQL Creating and Managing Tables
Referential Integrity MySQL
CS311 Database Management system
ITEC 313 Database Programming
Using SQL Server through Command Prompt
MySQL Explain examples
SQL: Constraints and Triggers
Module 5: Implementing Data Integrity by Using Constraints
Referential Integrity
SQL Creating and Managing Tables
Structured Query Language (Data definition Language)
Lecturer: Mukhtar Mohamed Ali “Hakaale”
لغة قواعد البيانات STRUCTURED QUERY LANGUAGE SQL))
SQL Creating and Managing Tables
For student, require values for name and address.
Referential Integrity
DATABASE SQL= Structure Query Language مبادئ قواعد بيانات
SQL Code for Byrnetube video
Rob Gleasure robgleasure.com
CS122 Using Relational Databases and SQL
Rob Gleasure robgleasure.com
Data Management Innovations 2017 High level overview of DB
Database Management System
Creating and Managing Database Tables
Data Definition Language
Rob Gleasure robgleasure.com
Rob Gleasure robgleasure.com
CS122 Using Relational Databases and SQL
CS1222 Using Relational Databases and SQL
CS122 Using Relational Databases and SQL
Indexes and more Table Creation
Instructor: Samia arshad
កម្មវិធីបង្រៀន SQL Programming ជាភាសាខ្មែរ Online SQL Training Course
SQL NOT NULL Constraint
SQL (Structured Query Language)
SQL AUTO INCREMENT Field
Presentation transcript:

Rob Gleasure R.Gleasure@ucc.ie robgleasure.com IS6126 Databases for Management Information Systems Lecture 3: SQL III – Solutions Rob Gleasure R.Gleasure@ucc.ie robgleasure.com

Exercise Solution We want to create a new table in our database called Inventory with the following criteria Three columns for Part_ID, Part_Name, and Part_of_Product All three of these columns set to not null The Part_ID set as primary key The Part_of_Product set as a foreign key to Products(ProductID) The default Part_Name is ‘Phalange’  CREATE TABLE Inventory ( Part_ID int PRIMARY KEY, Part_name varchar (50) NOT NULL DEFAULT 'Phalange', Part_of_Product varchar(255) NOT NULL , CONSTRAINT fk FOREIGN KEY (Part_of_Product ) REFERENCES Products(ProductID) );

Exercise Solution Run the following query to see what the database looks like INSERT INTO Inventory (Part_ID,Part_of_Product) VALUES ('1', '4'); INSERT INTO Inventory (Part_ID,Part_of_Product,Part_Name) VALUES ('3', '5', 'Cogs'); We want to create an index for the Part_Name, so that this can be searched independently? CREATE UNIQUE INDEX PtNm_index ON Inventory(Part_Name); We want to add a column to Inventory called Cost with type varchar(20)? ALTER TABLE Inventory ADD Cost varchar(20); We want to create a view [Phalanges] showing where Part_ID, Part_of_Product, and Cost where the Part_Name is ‘Phalange’? CREATE VIEW [Phalanges] AS SELECT Part_ID, Part_of_Product, Cost FROM Inventory WHERE Part_name='Phalange';