Using the Schema - data/statistics Write down the following SQL queries. Assume appropriate data types for each attribute by yourself. 1) Create Bill table. 2)Assume you forgot to set SID as foreign key during creation of Bill table, by default SID is declared as null.Now you have to declare SID as foreign key. 3)Add constraint on names of customer that ensures that names must start with alphabet.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
icon
Concept explainers
Question

Using the Schema - data/statistics Write down the following SQL queries. Assume appropriate data types for each attribute by yourself.

1) Create Bill table.

2)Assume you forgot to set SID as foreign key during creation of Bill table, by default SID is declared as null.Now you have to declare SID as foreign key.

3)Add constraint on names of customer that ensures that names must start with alphabet.

4)Delete constraint that was added in statement 3.

5)Add a new column in any one of the tables.

6)Delete the added column in statement 5

7)Show name of all those customers who have placed order after 23 June 2014 using subquery.

8)Show the data of those customers to who items were sold with SID 1 or 3 or 6

9)Show names of customers and items names of items sold to him

10)Make a vertical partition on customer table in such a way that changes in partitioned portion must be reflected on original table.

11) Update the city of customer as ‘Lahore’ where customer id is 3

12)Delete all those records of Items table whose price is between 15 and 240

13)Insert a record in any one of the tables

14)Change data type of name of customer to varchar(20)

15)Display details of all those items that are not sold yet

Items
Sales
ID
_Name
Price
Supplier
SID
S Date
CID
Ketchup
1
2012-5-23
1.
50
Block Factory
2012-5-24
2
Unique
Manufacturer
S&S
2
Salt
40
4
2016-4-23
3
2016-2-12
4
Soap
30
6
2016-1-10
International
4
Toothpaste
33
Brothers
Enterprise
General
5
Sugar
20
Bill
Traders
6.
Detergent
34
Alibaba
SID
ID
Express
2
1
3
Customer
4
CID
Name
2
1
City
Lahore
Peshawar
Sahiwal
Peshawar
2
4
Aqib
Suleman
Nadeem
2
2
2
4
4
Sarim
Sohail
Peshawar
4
3
6
Nadir
Okara
4
2
Nasir
Peshawar
4
4
Kamal
Lahore
Transcribed Image Text:Items Sales ID _Name Price Supplier SID S Date CID Ketchup 1 2012-5-23 1. 50 Block Factory 2012-5-24 2 Unique Manufacturer S&S 2 Salt 40 4 2016-4-23 3 2016-2-12 4 Soap 30 6 2016-1-10 International 4 Toothpaste 33 Brothers Enterprise General 5 Sugar 20 Bill Traders 6. Detergent 34 Alibaba SID ID Express 2 1 3 Customer 4 CID Name 2 1 City Lahore Peshawar Sahiwal Peshawar 2 4 Aqib Suleman Nadeem 2 2 2 4 4 Sarim Sohail Peshawar 4 3 6 Nadir Okara 4 2 Nasir Peshawar 4 4 Kamal Lahore
Expert Solution
steps

Step by step

Solved in 2 steps with 6 images

Blurred answer
Knowledge Booster
Query Syntax
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education