Create a schema called BuildingGo

Assignment Help Database Management System
Reference no: EM132691205

MIS602 Data Modelling & Database Design - Laureate International Universities

Task 1: Create a schema called "BuildingGo" and then write DDL queries to create the three tables with relevant keys as suggested in the above diagram and the sample data shown in the tables.
Query: create schema BuildingGo;
use BuildingGo;
Create Tables: create table Building(
Building_ID int,
Building_name varchar(20),
Built_year int,
Building_Capacity int,
Building_Address varchar(25),
primary key (Building_ID)
);
create table Owner(
Owner_ID int,
Owner_Fname varchar(10),
Owner_Lname varchar(7),
Owner_email varchar(20),
Owner_Phone varchar(8),
primary key (Owner_ID)
);
create table Apartment(
Apartment_ID int,
Total_rooms int,
Building_ID int,
Apartment_rent decimal(4,2),
primary key (Apartment_ID),
foreign key (Building_ID) references Building(Building_ID)
);
Task2: Write queries to insert 5 records into Building and Owner each.
insert into Building values(1001,'Lilli Pilli',1995,5000,'Wakefield street');
insert into Building values(1002,'Early Settler',2006,2000,'Flinders street');
insert into Building values(1003,'Horizon East',2018,5000,'Maldives street');
insert into Building values(1004,'Ocean Blue',2020,15000,'Wakefield street');
insert into Building values(1005,'Calm Place',2007,7000,'Ward street');
insert into Owner values(2001,'Hazel','Alex','[email protected]',04023466);
insert into Owner values(2002,'Saber','Khan','[email protected]',04013567);
insert into Owner values(2003,'Adam','Smith','[email protected]',04015748);
insert into Owner values(2004,'Lisa','Owen','[email protected]',04069874);
insert into Owner values(2005,'Heinz','Elex','[email protected]',04074569);
select * from Owner;
Task3: Write queries to insert 10 records into the Apartment table.
insert into Apartment values(1001,500.10,2,1001,2001);
insert into Apartment values(1002,600,3,1001,2002);
insert into Apartment values(1003,1000,2,1001,2001);
insert into Apartment values(1004,389,2,1001,2001);
insert into Apartment values(1005,400,2,1001,2001);
insert into Apartment values(1006,590.50,2,1001,2001);
insert into Apartment values(1007,345,2,1001,2001);
insert into Apartment values(1008,789,2,1001,2001);
insert into Apartment values(1009,900,2,1001,2001);
insert into Apartment values(1010,500,2,1001,2001);
Task 4: Write a query to display all the information about the buildings in the Building table.
Query: select * from Building;


Task 5: Write a query to display the building names of all buildings in the Building table.
Query: select building_name from Building;

Task 6: Write a query to display all the building names and their capacity.
Query: select building_name,building_capacity from Building;

Task 7: Write a query to update the Building_Capacity of ‘Lilly Pilly' to 2000 people.
Query: update Building set building_capacity = 2000 where building_name= 'Lilli Pilli';
select * from Building;

Task 8: Write a query to display the Building_ID and Building_Name of all the buildings with a capacity of above 3000 people.
Query: select Building_ID, Building_Name from Building where building_capacity>3000;

Task 9: Write a query to increase the rent of all apartments by 2% for all the apartments of Ocean Blue.

update Apartment set
Apartment_rent = Apartment_rent + (Apartment_rent * 0.02)
where Building_ID = 1004 ;

Task10: Write a query to display all the details of the apartments owned by Owner_ID ‘2003'.
Query: select * from Apartment where Owner_ID = 2003;

Task11: Write a query to display all the unique Building_Locations.
Query: select distinct building_address from Building;

Task12: Write a query to display Building_Name and Built_Year for all buildings built in 2001.
Query: select Building_name, Built_year from Building where Built_year = 2001;

Task13: Write a query to display the list of all the Builidng_Names with Buiding_capacity in the range of 1000 - 2000 people in descending order.
Query: select Building_name, Building_capacity from Building
where Building_capacity between 1000 AND 2000 order by Building_capacity DESC;

Task14: Write a query to display the total number of apartments in the Apartment table.
Query: select count(Apartment_ID) from Apartment;

Task15: Write a query to display the Owner_ID and the total number of apartments owned by each owner in ascending order.
select Owner_ID ,count(Apartment_ID) from Apartment
group by Owner_ID order by Owner_ID ASC;

Task16: Write a query to delete the record of the owners whose Owner_Fname contains the word ‘James'.
Query: delete from Owner where Owner_Fname = 'James';

Taskk17: Write a query to display all the apartments owned by the Owner ‘Hazel' as the Owner_Fname.
select * from Apartment A join Owner O
on A.Owner_ID = O.Owner_ID
where owner_Fname = 'Hazel';

Task18: Write a query to display all the apartment details and their corresponding Building_Names.
select A.Apartment_ID,A.Apartment_rent,A.Total_rooms,A.Owner_ID,A.Building_ID,
B.Building_name from A Apartment join B Building
on A.Building_ID = B.Building_ID;

Task19. Write a query to display all the apartment details in Building ‘Ocean Blue'.
select * from Apartment A join Building B
on A.Building_ID = B.Building_ID
where Building_name = 'Ocean Blue';

Task20 Write a query to display all the building names having more than 5 apartments
along with total count of apartments for each building displayed.
select building_name,count(*) from building
b inner join apartment a
ON A.building_id = B.building_id;


Task21 Write a query to display Owner_ID and Owner_Fname of all the owners who do not own any apartments.
select o.Owner_ID, o.Owner_Fname from Owner o
left join apartment a
on o.owner_id = a.owner_id
where Apartment_ID is null;

Task22: Write a query to display the building name, which has the apartment with the lowest weekly rent.
select building_name,min(apartment_rent) from
building b left join apartment a
on b.building_id = a.building_id;

Task23: Write a query to display all the Apartment_IDs, Apartment_Rent and their owner names of the apartments, which has a rent greater than 600 per week ordered in descending order by owner name.
select a.Apartment_ID,a.Apartment_rent, o.Owner_Fname from
Owner o left join apartment a
on o.owner_id = a.owner_id
where Apartment_rent>600 order by o.owner_Fname desc;

Attachment:- Data Modelling & Database Design.rar

Reference no: EM132691205

Questions Cloud

Which required for acquisition programs to make environment : Which is required for all acquisition programs to make environment issues are addressed? Environmental Impact Statement (EIS)
Indicate the class of ratios : You are a fresh analyst hired by the CFO of a small to midsized company. She is aware of the fact you wrote a paper of Financial Statement analysis and wants
Do you believe that some industries are unfairly targeted : In the land of free trade, the public does not view all industries as equal. Do you believe that is ethical? Do you believe that some industries are unfairly.
Determine the present value for the options : Alex Meir, Assuming an interest rate of 6%, determine the present value for the above options. Which option should Alex choose?
Create a schema called BuildingGo : Create a schema called "BuildingGo" and then write DDL queries to create the three tables with relevant keys as suggested in the above diagram
What is the cost of dubious year end inventory : What amount should be reported as cost of goods sold for the year? What is the selling price (retail value) of the goods in ending inventory?
Why do you think that experts worry about the job market : According to the article, "Job gains slow as layoffs persist", the U.S. economy created 661,000 jobs in September, causing the unemployment rate to drop from 8.
Does the country run a current account deficit or surplus : Does the country run a current account deficit or surplus? What are the implications of the current account deficit or surplus for the overall economy?
What will be the fund balance after the last payment is made : Assuming that the bank account pays 7% interest compounded annually, what will be the fund balance after the last payment is made on December 31, 2030?

Reviews

Write a Review

Database Management System Questions & Answers

  Assignment - Data Exploration And Preparation

31250 Introduction to Data Analytics and 32130 Fundamentals of Data Analytics Assignment. Identify the type of first 30 attributes

  Draw the corresponding entity-relationship diagram

Design an entity-relationship schema that most correctly and most completely captures the constraints expressed in the above description of the VINO application. Draw the corresponding entity-relationship diagram.

  Explain why is hashing all database inputs not considered

question 1 what are the similarities between an md5 hash and a fingerprint?question 2 how would you encrypt a web

  What is term for number used to reference an array element

What is the term for the number used to reference an array element? The number of elements in an array is called the ______ of the array. Arrays are most efficiently processed using ______

  Create a query that shows the count of books

Create a query that shows the count of books that are grouped by binding. Create an update query that increases all book prices by $1.00.

  CI7300 Data Management and Governance Assignment

CI7300 Data Management and Governance Assignment Help and Solution, Kingston University London - Assessment Writing Service

  Convenient database system

In short, there is a need for a more convenient database system. The machine on which the database is currently running is powerful enough to host the database server. The database should be accessible from four checkout stations that process rent..

  Create an actual web page document

Modify the XML document in Exercise 2 to include a namespace URL from which the elements of the XML document in Exercise 3 will be associated with. Make any changes to the XML document that are necessary as a result of the namespace URL inclusion.

  Discuss the benefits of enterprise resource planning

In an operation, the order in which work is to be tackled or the priorities given to work are often determined by predetermined set of rules. Briefly discuss 5.

  Draw e-r diagrams for hosiptal management system

How to write tables and draw E-R diagrams for hosiptal management system and how to normalize and cardinalities?

  Design a database schema and a set of front-end programs

Your task for this assignment is to design a database schema and a set of front-end programs for a student registration database

  Create a database.

Create a database.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd