Database Design and Development Flashcards
What law do companies have to adhere to concerning peoples private data?
The General Data Protection Regulation (GDPR)
Under the General Data Protection Regulation (GDPR) data must be:
•processed lawfully, fairly and in a transparent manner in relation to individuals •used for the declared purpose only •limited to the data needed for the declared purpose •accurate •not kept for longer than •necessary •held securely
Describe and exemplify entity-relationship diagrams
Entity – a place where information about a person, thing or concept is collected – a table.
Attribute – describe the facts, details or characteristic of an entity – a field.
What are the rules about an entity diagram?
crows foot- means one to many, one line that branches into three.
primary key- underline and label
foreign key- put an asterix* and label
What are the attribute types for a database?
— text —A combination of text and number e.g. name, address, telephone number. — number—whole numbers and decimal numbers. — date— usually in the format DD/MM/YYYY — time— usually in the format 00:00 but can be 00:00:00 — Boolean— true or false
What are the different types of validation?
Range – ensures data is
between a lower and
upper limit
Restricted Choice – limits the
user to a
list of
options.
Length Check – restricts the
number of
characters that
can be
entered.
Presence Check – ensures that
the field is
not left
blank – it is
required
What is a foreign key used for?
A FOREIGN KEY is a key used to link two tables together
What is a primary key used for?
A primary key is a unique identifier for a row/record in a table.
Display the team name, town, contact person and e-mail address for all teams in the east district from the table “team”
SELECT teamName, teamTown, teamContact, teamEmail
FROM Team
WHERE teamDistrict= “East”;
Display the surname, DOB and number of points scored for all players aged under 18 who have scored more than 5000 points from the table “Player”
SELECT playerSurname, playerDOB, playerPoints
FROM Player
WHERE playerAge< 18
AND playerPoints >= 5000;
Display the forename, surname and town of any players who play for a team based in Hamilton (equi-join):
SELECT playerForename, playerSurname, teamTown
FROM Player, Team
WHERE (Team.teamID= Player.teamID)
AND teamTown = “Hamilton”;
Display the forename, surname, number of points scored, team name and team ID for any players who have scored at least 4000 points for a team in the West district. As the teamID field appears in both tables, you must indicate which table you want to use, e.g. player.teamID (equi-join):
SELECT playerForname, playerSurname, playerPoints, teamName, Team.teamID FROM Team, Player WHERE (Team.teamID=Player.teamID) AND (playerPoints>= 4000) AND (teamDistrict="West");
Display the forename, surname,number of points scored,team name and team ID for any players who has scored afewer than 1000 points this season, with the player who has scored the most points listed first:
SELECT playerForename, playerSurname, teamID, playerPoints
FROM Player
WHERE playerPoints < 1000
ORDER BY playerPoints DESC;
Display the forename, surname and teamID of all players from teams based in Glasgow. The listing should be in alphabetical order of surname. players with the same surname should be listed in alphabetical order of first name.
SELECT playerForename, playerSurname, Player.TeamID,
FROM Player,Team
WHERE teamTown = “Glasgow”
ORDER BY playerSurname ASC, playerForename ASC;
Add the following data into the table player: PLAY2048 Stewart Chalmers TEAM007
INSERT INTO PLAYER (playerID, playerForename,playerSurname,teamID)
VALUES (“PLAY2048”,”Stewart”,”Chalmers”,”TEAM007”);