代做DTS207TC Database Development and Design帮做Python编程

Module code and Title

Database Development and Design (DTS207TC)

School Title

School of AI and Advanced Computing

Assignment Title

002: Assessment Task 2 (CW)

Submission Deadline

23:59, 12th Dec (Friday)

Final Word Count

NA

Database Development and Design (DTS207TC)

Assessment 002: Individual Coursework

Weight: 40%

Maximum Marks: 100

Overview & Outcomes

This course work will be assessed for the following learning outcomes:

A. Identify and apply the principles underpinning transaction management within DBMS.

E. State the main concepts in data warehousing and data mining.

Submission

You must submit the following files to LMO:

1)A report named as Your_Student_ID.pdf.

2)A directory containing all your source code, named as Your_Student_ID_code.

NOTE: The report shall be in A4 size, size 11 font, and shall not exceed 9 pages in length. You can include only key code snippets in your reports. The complete source code can be placed in the attachment.

Question 6: Storage Management (40 marks)

In a database storage system, the cache hit rate has a significant impact on its performance. Different cache strategies will result in different cache hit ratios. Now, we have recorded 2 datasets (please download from LMO), containing CPU access requests to memory for a period of time. They both have 10,000 items from addresses 0 to 63. We will simulate the process of the CPU reading and caching data from the memory through a program in the table below (also can be download from LMO) . Please run the program to compare the hit rates of different strategies:

Python

import random

from collections import deque

class RandomPolicy:

def __init__(self, size):

self.size = size

self.cache = []

self.name = 'rr'

random.seed(207)

def access(self, current):

if current in self.cache: # hit!

return True

self.cache.append(current)

if len(self.cache) > self.size: # exceed

self.cache.remove(random.choice(self.cache))

return False

class FifoPolicy:

def __init__(self, size):

self.size = size

self.cache = deque()

self.name = 'fifo'

def access(self, current):

if current in self.cache: # hit!

return True

if len(self.cache) == self.size: # full

self.cache.popleft()

self.cache.append(current)

return False

def run_test(trace, pol):

hit = []

for i in range(len(trace)):

# update cache

hit += [pol.access(trace[i])]

return sum(hit) / len(hit)

if __name__ == '__main__':

# parameters

caps = [1, 2, 3, 4, 5]

# load trace from file

traces = []

for name in ['trace1.txt', 'trace2.txt']:

with open(name) as f:

traces += [list(eval(f.read()))]

# test all strategies

strategies = [

FifoPolicy,

RandomPolicy,

]

# run strategy over trace

for i in range(len(traces)):

for cap in caps:

for Strategy in strategies:

pol = Strategy(size=cap)

print(f'data={i +

1},\tcap={cap},\tname={pol.name},\thitrate={run_test(traces[i], pol)}')

print()

You need to analyze the characteristics of this data and analyze why the hit rates of the two strategies are different on the two data sets (20 mark). Design and implement a strategy which can achieve better results than the RandomPolicy strategy on the trace2 data set. Record the hit rates you observed in the table below (with snapshot) (20 marks).

Cache Size

RR

Your Policy

1

2

3

4

5

Question 7: Indexing (30 marks)

Consider a hard disk with a sector size of B = 512 bytes. A CUSTOMER file contains approximately r = 40,000 records. Each record includes the following fields: Name (30 bytes), Ssn (9 bytes), Email (30 bytes), Address (50 bytes), Phone (15 bytes), and Birth_date (8 bytes). The Ssn field is the primary key.

The file system uses 4KB blocks for allocation.

(a) Calculate the number of blocks required for an unspanned organization. Then, discuss how the discrepancy between sector size and block size might affect sequential access performance, and whether you would recommend using a different block size for this scenario. (6 marks)

(b) The records are physically ordered on Ssn. Calculate the maximum number of block accesses for a binary search. During system testing, developers notice that batch queries processing large ranges of Ssn values perform. 30% slower than expected when using binary search as the primary lookup method. Provide two possible explanations for your scenario. (6 marks)

(c) A sparse index is built on Ssn. Calculate the number of block accesses to retrieve a record using this index in ideal scenario. During usage, it is found that the performance of the index search continues to decline. Identify two potential reasons why the index performance gain is less than theoretical expectations. (6 marks)

(d) A multi-level primary index is constructed. During the design review, two proposals are made: Proposal A: Use the standard multi-level index structure; Proposal B: Based on Proposal A, select 10 index blocks and cache them persistently in memory. Calculate the number of index levels needed for the Proposal A. Then, compare the two proposals in terms of implementation complexity and computation time under a workload with 10% of the Ssn accounting for 90% of the queries. (6 marks)

(e) A B+ tree index is built with order p = 50. Calculate the maximum number of records a height 4 tree can index. During maintenance, it's observed that, during frequent insertion and deletion operations, the tree height changes frequently between 3 and 4 even with relatively stable data size.

Explain what might be causing this fluctuation and suggest one strategy to stabilize the tree height with optimal performance. (6 marks)

Question 8: Transaction (30 marks)

Consider a database with a relation Account (AccountID, Balance) and initial state:

AccountID

Balance

1

110

2

10

(a) The following transactions represent a fund transfer (T1) and a real-time balance report (T2) that run concurrently. (10 marks)

T1 (Transfer)

T2 (Report)

1.    begin transaction

1.    begin transaction

2.    update Account set Balance =

Balance - 100 where AccountID =

2.    select sum(Balance) from Account;

1;

3.    update Account set Balance =

Balance + 100 where AccountID =

3.    commit;

2;

4.    commit;

The application requirement states that the report must never reflect a financially inconsistent state.

However, under certain database configurations, T2 might output a total of 20 (instead of the correct 120).

(i) Explain under which isolation level(s) this inconsistent total of 20 could occur, and describe the exact sequence of operations in a concurrent schedule that leads to this result.

(ii) The development team proposes using the SERIALIZABLE isolation level to fix this issue. Critically

evaluate this proposal by discussing one key advantage and two potential drawbacks (considering both performance and system complexity) for this specific application scenario.

(b) Now consider these transactions: a process adding a new account (T3), and an audit process

.

T3(New Account)

T4 (Audit)

1.    begin transaction

1.    begin transaction

2.    insert into Account values (3, 150);

2.    select sum(Balance) from Account;

3.    commit;

3.    select sum(Balance)

from Account;

4.    commit;

Suppose the application requirement for the audit is that it must have a consistent view of the database throughout its execution.

(i) Is it possible for the two SUM queries in T4 to return different values? Analyze this possibility under at least three different isolation levels, providing a brief concurrent schedule for each case where the results differ.

(ii) During a system design review, an engineer suggests: "We can just use the REPEATABLE READ

isolation level to solve all our concurrency problems in this audit process." Write a brief response  evaluating this suggestion. Your response should consider whether this is sufficient, necessary, and practical for meeting the audit requirement.

(c) Consider the following observation from production logs: (10 marks)

l T5 (Data Maintenance): Inserts 100 new account records in a single transaction.

l T6 (Analytics Query): Runs SELECT COUNT(*) FROM Account; twice within its transaction and gets two different results.

The team initially diagnosed this as a "phantom read."

(i) Under which isolation level(s) is this phenomenon possible?

(ii) A DBA comments: "While this looks like a phantom read, the actual impact and the appropriate fix might be different if those 100 new accounts were all inserted with a zero balance." Briefly explain the DBA's reasoning. Why might the business impact and the technical solution be different if the new accounts have a zero balance, even though the phenomenon looks the same?



热门主题

课程名

mktg2509 csci 2600 38170 lng302 csse3010 phas3226 77938 arch1162 engn4536/engn6536 acx5903 comp151101 phl245 cse12 comp9312 stat3016/6016 phas0038 comp2140 6qqmb312 xjco3011 rest0005 ematm0051 5qqmn219 lubs5062m eee8155 cege0100 eap033 artd1109 mat246 etc3430 ecmm462 mis102 inft6800 ddes9903 comp6521 comp9517 comp3331/9331 comp4337 comp6008 comp9414 bu.231.790.81 man00150m csb352h math1041 eengm4100 isys1002 08 6057cem mktg3504 mthm036 mtrx1701 mth3241 eeee3086 cmp-7038b cmp-7000a ints4010 econ2151 infs5710 fins5516 fin3309 fins5510 gsoe9340 math2007 math2036 soee5010 mark3088 infs3605 elec9714 comp2271 ma214 comp2211 infs3604 600426 sit254 acct3091 bbt405 msin0116 com107/com113 mark5826 sit120 comp9021 eco2101 eeen40700 cs253 ece3114 ecmm447 chns3000 math377 itd102 comp9444 comp(2041|9044) econ0060 econ7230 mgt001371 ecs-323 cs6250 mgdi60012 mdia2012 comm221001 comm5000 ma1008 engl642 econ241 com333 math367 mis201 nbs-7041x meek16104 econ2003 comm1190 mbas902 comp-1027 dpst1091 comp7315 eppd1033 m06 ee3025 msci231 bb113/bbs1063 fc709 comp3425 comp9417 econ42915 cb9101 math1102e chme0017 fc307 mkt60104 5522usst litr1-uc6201.200 ee1102 cosc2803 math39512 omp9727 int2067/int5051 bsb151 mgt253 fc021 babs2202 mis2002s phya21 18-213 cege0012 mdia1002 math38032 mech5125 07 cisc102 mgx3110 cs240 11175 fin3020s eco3420 ictten622 comp9727 cpt111 de114102d mgm320h5s bafi1019 math21112 efim20036 mn-3503 fins5568 110.807 bcpm000028 info6030 bma0092 bcpm0054 math20212 ce335 cs365 cenv6141 ftec5580 math2010 ec3450 comm1170 ecmt1010 csci-ua.0480-003 econ12-200 ib3960 ectb60h3f cs247—assignment tk3163 ics3u ib3j80 comp20008 comp9334 eppd1063 acct2343 cct109 isys1055/3412 math350-real math2014 eec180 stat141b econ2101 msinm014/msing014/msing014b fit2004 comp643 bu1002 cm2030
联系我们
EMail: 99515681@qq.com
QQ: 99515681
留学生作业帮-留学生的知心伴侣!
工作时间:08:00-21:00
python代写
微信客服:codinghelp
站长地图