Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Lab 3-Introduction to SQ 1. 2. Write SQL queries for each of the tasks using MySQL workbench. You cannot use Workbench's GUI to create database

image text in transcribedimage text in transcribed

Lab 3-Introduction to SQ 1. 2. Write SQL queries for each of the tasks using MySQL workbench. You cannot use Workbench's GUI to create database schemas and tables - you must write your own SQL statements 3. Follow the underscore convention when naming your database schema, entities and attributes Consider the following two tables and their logical structures accounts Field name Primarv Kev Data tvpe account id balance Is null? Is auto-increment? no no es no no INT DOUBLE VARCHAR 30) no DATETIME VARCHAR 30) no es no no no no date opened no status no no transactions Field name transaction id date time amount remaining balance no account id Primarv Kev |Data tvpe Is null? Is auto-increment? INT DATETIME no DOUBLEno DOUBLEno INT no es no no es no no no no no no Task 1: Create a database called bank using CREATE DATABASE statement. Task 2: In database bank, create the following entity tables 1. account 2. transactions Each tables logical structure should correspond to the descriptions provided in this assignment. Use CREATE TABLE statement. Task 3: Use ALTER TABLE statement to create a foreign key connection account id in transactions table to account id in accounts table Task 4: For each entity table, insert rows using INSERT statement: 1. At least 3 accounts in the accounts table 2. At least transactions table. Make sure that at least one You can make up your own data for the INSERT statements. Task 5: Write a SELECT statement to display top 2 accounts sorted by date created in transactions in the account has multiple transactions. descending order. Task 6: Write a SELECT statement to display transactions for a particular account number (hard-code account number in the where clause) Task 7: Write an UPDATE statement to update all account statuses to active. Task 8: DELETE one row ofyour choice from transactions table. Be careful - make sure to write a correct WHERE clause

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Fred R. McFadden, Jeffrey Slater, Mary B. Prescott

5th Edition

0805360549, 978-0805360547

More Books

Students also viewed these Databases questions