/*Muhammad Usama Waseem. Creating database */
create database Musica;
/*Muhammad Usama Waseem. Creating table Label */
USE Musica;
create table Label(LabelId int NOT NULL primary key, LabelName varchar(100) NOT NULL, Phone varchar(15) NOT NULL, Street varchar(50) NOT NULL, PostalCode varchar(20), City varchar(50) NOT NULL, Country varchar(50) NOT NULL);
Task 2 a (2)
/*Muhammad Usama Waseem. Creating table Label */
USE Musica;
Insert into Label(LabelId, LabelName, Phone, Street, PostalCode, City, Country) values
(1, ‘Polydor’, ‘+457832133222’, ‘N/A’, ‘23456’, ‘NY’, ‘USA’),
(2, ‘Rocky’, ‘+427832133222’, ‘N/A’, ‘53456’, ‘ZK’, ‘UK’),
(3, ‘Technique’, ‘+447832133222’, ‘N/A’, ‘33456’, ‘ZK’, ‘SPAIN’);
Task 2 a (3)
/*Muhammad Usama Waseem. Select details of table Label */
USE Musica;
select * from Label;
Task 2 a (4)
/*Muhammad Usama Waseem. Update Polydor to Asterial and select Label Name for all austalian for table Label */
USE Musica;
Update Label set Country = ‘Australia’ where LabelName = ‘Polydor’;
Select LabelName from Label Where Country = ‘Australia’;
Task 2 a (5)
/*Muhammad Usama Waseem. Creating table Release */
USE Musica;
create table Release(ReleaseId int NOT NuLL primary key, ReleaseTitle varchar(100) NOT NULL, ReleaseDate date NOT NULL, LabelId int NOT NULL);
/*Muhammad Usama Waseem. Add foreign key to Release Table from Label table */
USE Musica;
alter table Release add Foreign Key(LabelId) references Label(LabelId);
Task 2 a (6)
/*Muhammad Usama Waseem. Insert into table Release */
USE Musica;
Insert into Release(ReleaseId, ReleaseTitle, ReleaseDate, LabelId) values
(1, ‘Maze -M’, ‘2018-01-01’, 1),
(2, ‘Regea -R’, ‘2018-01-02’, 2),
(3, ‘Deep House -H’, ‘2018-01-03’, 3),
(4, ‘Electro -E’, ‘2018-01-05’,1),
(5, ‘Country -C’, ‘2018-01-07’, 2),
(6, ‘RNB -R’, ‘2018-01-11’,3);
/*Muhammad Usama Waseem. Select where title start from M-Z from table Release */
USE Musica;
select ReleaseTitle, ReleaseDate from Release where ReleaseTitle LIKE ‘[M-Z]%’;
Task 2 a (7)
/*Muhammad Usama Waseem. Trying to delete from table Label */
USE Musica;
Delete from Label;
Task 2 a (8)
/*Muhammad Usama Waseem. Display all Label names, along with all of their releases, grouped by Label */
USE Musica;
Select LabelName, ReleaseTitle from Label inner join Release on Release.LabelId = Release.LabelId Group by Label.LabelName;
/*Muhammad Usama Waseem. Display all Label names, along with all of their releases, without grouped by Label */
USE Musica;
Select LabelName, ReleaseTitle from Label inner join Release on Release.LabelId = Release.LabelId;
Task 2 b (1)
/*Muhammad Usama Waseem. Creating all the tables*/
USE Musica;
create table Song(SongId int NOT NULL primary key, SongName varchar(60) NOT NULL, Length decimal(10, 2));
create table SongWrittenBy(SongWrittenById int NOT NULL primary key, SongId int NOT NULL, ArtistId int NOT NULL, SongSungById int NOT NULL, LabelId int NOT NULL, ArtistTypeId int not null);
create table Artist(ArtistId int NOT NULL primary key, FirstName varchar(30) NOT NULL, LastName varchar(30) NOT NULL, Gender varchar(6) NOT NULL, DOB date Not Null, Nationality varchar(50) NOT NULL, ArtistTypeId int NOT NULL);
Create table ArtistType(ArtistTypeId int NOT NULL primary key, ArtistTypeName varchar(30) NOT NULL);
Create table SongSungBy(SongSungById int NOT NULL primary key, SongSungByName varchar(60) NOT NULL);
/*Muhammad Usama Waseem. Adding tables relationship where applicable in the database*/
alter table SongWrittenBy add foreign key(SongId) references Song(SongId);
alter table SongWrittenBy add foreign key(ArtistId) references Artist(ArtistId);
alter table SongWrittenBy add foreign key(SongSungById) references SongSungBy(SongSungById);
alter table SongWrittenBy add foreign key(labelId) references Label(LabelId);
alter table SongWrittenBy add foreign key(ArtistTypeId) references ArtistType(ArtistTypeId);
Task 2 b (2)
/*Muhammad Usama Waseem. Insert into SongSungBy table*/
insert into SongSungBy(SongSungById, SongSungByName) values
(1, ‘Sung by Duets’),
(2,’Larger Collection’);
/*Muhammad Usama Waseem. Insert into ArtistType table*/
insert into ArtistType(ArtistTypeId, ArtistTypeName) values
(1, ‘Singers’),
(2,’Writers’);
/*Muhammad Usama Waseem. Insert into Song table*/
insert into song(SongId, SongName, Length)values
(1, ‘Shape of You’, 0),
(2, ‘Atlantic City’, 3.57),
(3, ‘Atlantic City’, 2.58),
(4, ‘I’m Waiting for The Man’, 4.38),
(5, ‘Life on Mars’, 3.52);
/*Muhammad Usama Waseem. Insert into Label table*/
Insert into Label(LabelId, LabelName, Phone, Street, PostalCode, City, Country) values
(4, ‘Planet’, ‘+957832133222’, ‘N/A’, ‘93456’, ‘PL’, ‘USA’),
(5, ‘Columbia’, ‘+827832133222’, ‘N/A’, ‘83456’, ‘PL’, ‘UK’);
/*Muhammad Usama Waseem. Insert into artists table*/
insert into artist(ArtistId, FirstName, LastName, Gender, DOB, Nationality) values
(1, ‘Ed’, ‘Sheeran’, ‘M’, ‘1978-07-01’, ‘UK’),
(2, ‘Bruce’, ‘Springsteen’,’M’, ‘1989-03-01’, ‘USA’),
(3, ‘David’, ‘Bowie’, ‘M’, ‘1980-03-01’, ‘AUSTRALIA’),
(4, ‘Lou’, ‘Reed’, ‘M’, ‘1977-07-01’, ‘COLUMBIA’);
/*Muhammad Usama Waseem. Inserting into SongDetail table*/
insert into SongDetail(SongWrittenById, SongId, ArtistId, SongSungById, LabelId, ArtistTypeId)values
(1, 1, 1, 1, 4, 1),
(2, 1, 1, 1, 4, 2),
(3, 2, 2, 1, 4, 1),
(4, 2, 1, 1, 4, 2),
(5, 3, 2, 1, 5, 1),
(6, 3, 2, 1, 5, 2),
(7, 4, 3, 1, 5, 1),
(8, 4, 4, 1, 5, 2),
(9, 5, 3, 1, 5,1),
(10, 5, 3, 1, 5, 2);
Task 2 b (3)
/*Muhammad Usama Waseem. Selecting writers with names table*/
select FirstName, LastName, SongName from Artist inner join SongDetail on
SongDetail.ArtistId = Artist.ArtistId INNER JOIN Song on Song.SongId = SongDetail.SongId
INNER JOIN ArtistType on ArtistType.ArtistTypeId = SongDetail.ArtistTypeId
where ArtistType.ArtistTypeName = ‘Writers’;
Task 2 b (4))
/*Muhammad Usama Waseem. Selecting name and release table*/
select Release.ReleaseTitle, Artist.FirstName, Artist.LastName, Label.LabelName from
Release inner join Label ON Label.LabelId = Release.LabelId INNER JOIN SongDetail ON
SongDetail.LabelId = Label.LabelId INNER JOIN Artist ON Artist.ArtistId = SongDetail.ArtistId;
Task 2 b (5)
/*Muhammad Usama Waseem. Selecting artist not written songs*/
select * from Artist INNER JOIN SongDetail on SongDetail.ArtistId = Artist.ArtistId INNER JOIN
ArtistType ON ArtistType.ArtistTypeId = SongDetail.ArtistTypeId where
SongDetail.ArtistId NOT IN (Select SongDetail.ArtistId FROM
SongDetail INNER JOIN ArtistType ON ArtistType.ArtistTypeId = SongDetail.ArtistTypeId
WHERE ArtistType.ArtistTypeId = 2);
Task 2 b (6)
/*Muhammad Usama Waseem. Selecting artist written and sung atleast one songs*/
select Artist.FirstName, Artist.LastName from Artist INNER JOIN SongDetail on
SongDetail.ArtistId = Artist.ArtistId INNER JOIN
ArtistType ON ArtistType.ArtistTypeId = SongDetail.ArtistTypeId where
SongDetail.ArtistId IN (Select SongDetail.ArtistId FROM
SongDetail INNER JOIN ArtistType ON ArtistType.ArtistTypeId = SongDetail.ArtistTypeId
WHERE ArtistType.ArtistTypeId = 2);
Task 2 b (7)
/*Muhammad Usama Waseem. Selecting total length of the songs sung by David Bowie*/
select SUM(Song.Length) from song inner join SongDetail on SongDetail.SongId = Song.SongId
INNER JOIN Artist ON Artist.ArtistId = SongDetail.ArtistId INNER JOIN ArtistType ON
ArtistType.ArtistTypeId = SongDetail.ArtistTypeId WHERE Artist.ArtistId = 3 AND
ArtistType.ArtistTypeName = ‘Singers’;
(“Basic Database Security: Step by Step – Information Security Magazine”, 2018) Databases stores organization’s information which are most important. This information consist of confidential and public information. So in order to separate the accessibility of private and public information, a database access rights need to be defined in application level or database level. (“What is Database Security? – Definition from Techopedia”, 2018) An organization storing customer data must ensures that data are safeguarded from unauthorized access. The potential danger of customer data are fraud which someone can lose money or data infiltration which may results in damage of privacy level.
They are several techniques which can be used to secure database data include (“5 Key Steps to Ensuring Database Security”, 2018):
Task 3 (2)
Graphical representation of data aid in representing relational databases. It gives ability to both the client and developer to understand the need of an application. The following are the benefits of using Entity relational diagram to design relational database (“Advantages and Disadvantages of ER Model in DBMS – EDUGRABS”, 2018):
References
“Database Legal Protection (BitLaw)”, Bitlaw.com, 2018. [Online]. Available: https://www.bitlaw.com/copyright/database.html. [Accessed: 05- Jun- 2018].
“Web Development Blog: What is ERD and Why Is It Important In Website Development?”, Superiorwebsys.com, 2018. [Online]. Available: https://www.superiorwebsys.com/58-what-is-erd-and-why-is-it-important-in-website-development/. [Accessed: 05- Jun- 2018].
Advantages and Disadvantages of ER Model in DBMS – EDUGRABS. (2018). Retrieved from https://www.edugrabs.com/advantages-and-disadvantages-of-er-model/
5 Key Steps to Ensuring Database Security. (2018). Retrieved from https://www.dbta.com/Editorial/Think-About-It/5-Key-Steps-to-Ensuring-Database-Security-95307.aspx
What is Database Security? – Definition from Techopedia. (2018). Retrieved from https://www.techopedia.com/definition/29841/database-security
Basic Database Security: Step by Step – Information Security Magazine. (2018). Retrieved from https://searchsecurity.techtarget.com/magazineContent/Basic-Database-Security-Step-by-Step
Essay Writing Service Features
Our Experience
No matter how complex your assignment is, we can find the right professional for your specific task. Contact Essay is an essay writing company that hires only the smartest minds to help you with your projects. Our expertise allows us to provide students with high-quality academic writing, editing & proofreading services.Free Features
Free revision policy
$10Free bibliography & reference
$8Free title page
$8Free formatting
$8How Our Essay Writing Service Works
First, you will need to complete an order form. It's not difficult but, in case there is anything you find not to be clear, you may always call us so that we can guide you through it. On the order form, you will need to include some basic information concerning your order: subject, topic, number of pages, etc. We also encourage our clients to upload any relevant information or sources that will help.
Complete the order formOnce we have all the information and instructions that we need, we select the most suitable writer for your assignment. While everything seems to be clear, the writer, who has complete knowledge of the subject, may need clarification from you. It is at that point that you would receive a call or email from us.
Writer’s assignmentAs soon as the writer has finished, it will be delivered both to the website and to your email address so that you will not miss it. If your deadline is close at hand, we will place a call to you to make sure that you receive the paper on time.
Completing the order and download