Notes![what is notes.io? What is notes.io?](/theme/images/whatisnotesio.png)
![]() ![]() Notes - notes.io |
USE Cinema
CREATE TABLE Movies(
Id INT PRIMARY KEY IDENTITY,
Name NVARCHAR(70) NOT NULL,
Rate INT CHECK(Rate BETWEEN 0 AND 10),
DirectorId INT REFERENCES Directors(Id)
)
CREATE TABLE Directors(
Id INT PRIMARY KEY IDENTITY,
Name NVARCHAR(70) NOT NULL,
Surname NVARCHAR(100) NOT NULL,
Age INT CHECK(Age >= 18),
)
CREATE TABLE Genres(
Id INT PRIMARY KEY IDENTITY,
Name NVARCHAR(70) NOT NULL
)
Create Table MovGenres(
Id INT PRIMARY KEY IDENTITY,
MovId INT REFERENCES Movies(Id),
GenId INT REFERENCES Genres(Id)
)
CREATE TABLE Actors(
Id INT PRIMARY KEY IDENTITY,
Name NVARCHAR(70) NOT NULL,
Surname NVARCHAR(100) NOT NULL,
Age INT CHECK(Age >= 18),
)
Create Table MovActors(
Id INT PRIMARY KEY IDENTITY,
MovId INT REFERENCES Movies(Id),
ActId INT REFERENCES Actors(Id)
)
Select * From Movies
Where Movies.Rate > 8
Select m.Name , m.Rate From Movies As m
Order By m.Rate DESC
Select (a.Name + ' ' + a.Surname) As 'Fullname' , a.Age From Actors As a Where a.Age > 40
Union
Select (d.Name + ' ' + d.Surname) As 'Fullname' , d.Age From Directors As d Where d.Age > 40
Select m.Name , m.Rate , (d.Name + ' ' + d.Surname) As 'Fullname' From Movies As m
Join
Directors As d
On
m.DirectorId = d.Id
Order By d.Name
Select m.Name , m.Rate , (d.Name + ' ' + d.Surname) As 'Fullname' , ( a.Name + ' ' + a.Surname) As 'Fullname' From Movies As m
Join
Directors As d
On
d.Id = m.DirectorId
Join
MovActors As mA
On
mA.MovId = m.Id
Join
Actors As a
On
a.Id = mA.ActId
Select (a.Name + ' ' + a.Surname) As 'Fullname' , m.Name , g.Name , (d.Name + ' ' + d.Surname) As 'Fullname' , m.Rate From Actors As a
Join
MovActors as mA
On
mA.ActId = a.Id
Join
Movies As m
On
m.Id = mA.MovId
Join
MovGenres As mG
On
mG.MovId = m.Id
Join
Genres As g
On
g.Id = mG.Id
Join
Directors As d
On
m.DirectorId = d.Id
Select d.Name , d.Surname, (Select Count(*) from Movies as m Where d.Id = m.DirectorId) As 'MovieCount' From Directors As d
![]() |
Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 14 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team