Presentation is loading. Please wait.

Presentation is loading. Please wait.

Digital recordkeeping and preservation I

Similar presentations


Presentation on theme: "Digital recordkeeping and preservation I"— Presentation transcript:

1 Digital recordkeeping and preservation I
Databases : DML ARK2100 Digital recordkeeping and preservation I 2017 Thomas Sødring P48-R407

2 Data Manipulation Language (DML)
DML is a database language designed for manipulating data in relational databases DML is used to insert, update or delete data in a table INSERT UPDATE DELETE

3 DML INSERT Data is inserted into a relation one row at a time
The minimum you need is the primary key Unless there are restrictions on other attributes e.g. NOT NULL Even if you are inserting many rows (batch import), data is inserted one tuple at a time Data that is across two rows in different tables can be inserted together There is no requirement for transaction Remember referential integrity

4 INSERT INTO TABLE (attributtelist) VALUES (valuelist);

5 INSERT INTO TABLE VALUES ();

6 INSERT Car # Example 1 INSERT INTO Car
(registrationNr, chassisNr, colour, manufacturer, model) VALUES ("ZQ10000", " ", "black", "Audi", "A3"); # Example 2 INSERT INTO Car VALUES

7 INSERT Car

8 INSERT Car ??

9 INSERT Car

10 After INSERT Car

11 INSERT Car (multiple rows)
INSERT INTO Car (registrationNr, chassisNr, colour, manufacturer, model) VALUES ("ZQ10001", " ", "red", "Audi", "A5"), ("ZQ10002", " ", "blue", "VW", "Golf");

12 INSERT Car (multiple rows)

13 After INSERT Car (multiple rows)

14 Take a look at Car

15 SQL UPDATE A tuple can be updated/changed with the UPDATE command
You can change the values of fields Many tuples can be updated simultaneously with one command Updated one at a time Remember, there is usually no [CTRL] + [Z] (undo) button You can do a lot of harm to a database if you are not careful

16 UPDATE SET WHERE;

17 UPDATE TABLE SET Attribute='value' WHERE;

18 UPDATE Car SET registrationNr = "ZQ10099" WHERE

19 UPDATE Car

20 After UPDATE Car

21 UPDATE Car SET colour = "pink" WHERE registrationNr = "ZQ10099" ;

22 UPDATE Bil

23 After UPDATE Car

24 Take a look at Car

25 UPDATE Car UPDATE Car SET colour = "red"; What will happen here?

26 Update Car

27 Take a look at Car

28 DELETE FROM WHERE;

29 DELETE FROM TABLE WHERE;

30 DELETE Car DELETE FROM Car WHERE registrationNr = "ZQ10099" ;

31 DELETE Car

32 After DELETE Car

33 Take a look at Car

34 DELETE Car DELETE FROM Car; What will happen here?

35 Fill up the Car relation
The following link will allow you to insert a lot of data into the Car relation The username is your studentId Use the password you created for mysql/phpmyadmin The database must exist and contain a table called Car

36 Car with many records

37 TRUNCATE Car; Truncate
We can easily empty the table using the truncate command You need to run the script again to fill up the table TRUNCATE Car;

38 Summary Manipulation of data is done using insert, update or delete
It's very easy to create problems with your data Always use the WHERE clause when you create an UPDATE or DELETE command Care must be taken especially with these as there is usually no undo button The application on top of the database might break if you aren't careful


Download ppt "Digital recordkeeping and preservation I"

Similar presentations


Ads by Google