首页
网站开发
桌面应用
管理软件
微信开发
App开发
嵌入式软件
工具软件
数据采集与分析
其他
首页
>
> 详细
代写COMP9315、代做SQL编程语言
项目预算:
开发周期:
发布时间:
要求地区:
COMP9315 24T1 - Assignment 1
1/9
Deadline
Pre-requisites:
Late Penalty:
Marks:
Submission:
COMP9315 24T1 Assignment 1
Adding a PersonName Data Type to
PostgreSQL
DBMS Implementation
Last updated: Sunday 25th February 9:26pm
Most recent changes are shown in red ... older changes are shown in brown.
Aims
This assignment aims to give you
an understanding of how data is treated inside a DBMS
practice in adding a new base type to PostgreSQL
The goal is to implement a new data type for PostgreSQL, complete with
input/output functions, comparison operators, formatting functions, and the
ability to build indexes on values of the type.
Summary
Friday 15 March, 11:59pm
before starting this assignment, it would be useful to
complete Prac Work P04
0.03 marks off the final mark for each hour late
for the first 5 days late; total mark of zero thereafter
This assignment contributes 15 marks toward your total
mark for this course.
Webcms3 > Assignments > Ass1 Submission > Make
Submission
or, on CSE machines, give cs9315 ass1 pname.c
pname.source
Make sure that you read this assignment specification carefully and completely
before starting work on the assignment.
Questions which indicate that you haven't done this will simply get the
response "Please read the spec".
We use the following names in the discussion below
PG_CODE ... the directory where your PostgreSQL source code is located
(on vxdb, /localstorage/$USER/postgresql-15.6/)
PG_HOME ... the directory where you have installed the PostgreSQL
binaries (on vxdb, /localstorage/$USER/pgsql/bin/)
PG_DATA ... the directory where you have placed PostgreSQL's data (on
vxdb, /localstorage/$USER/pgsql/data/)
COMP9315 24T1 - Assignment 1
2/9
PG_LOG ... the file where you send PostgreSQL's log output (on vxdb,
/localstorage/$USER/pgsql/data/log)
Introduction
PostgreSQL has an extensibility model which, among other things, provides a
well-defined process for adding new data types into a PostgreSQL server. This
capability has led to the development by PostgreSQL users of a number of
types (such as polygons) which have become part of the standard distribution.
It also means that PostgreSQL is the database of choice in research projects
which aim to push the boundaries of what kind of data a DBMS can manage.
In this assignment, we will be adding a new data type for dealing with people's
names. "Hmmm", you say, "but aren't they just text strings, typically
implemented as two attributes, one for family name and one for given names?".
That may be true, but making names into a separate base data type allows us
to explore how we store and manipulate them.
One common way of writing names (e.g. used in UNSW student systems) is
Shepherd,John Andrew
Swift, Taylor
Martin, Eric Andre
Lakshminarasimhan,Venkateswaran Chandrasekara
Marshall-Martin, Sally Angela
Featherstone,Albert Basil Ernest George Harold Randolph William
i.e.
FamilyName,GivenNames
Note: some of the examples above have a space after the comma; some don't.
We give a more precise description of what text strings are valid PersonNames
below.
Adding Data Types in PostgreSQL
The process for adding new base data types in PostgreSQL is described in the
following sections of the PostgreSQL documentation:
38.13 User-defined Types
38.10 C-Language Functions
38.14 User-defined Operators
SQL: CREATE TYPE
SQL: CREATE OPERATOR
SQL: CREATE OPERATOR CLASS
Section 38.13 uses an example of a complex number type, which you can use
as a starting point for defining your PersonName data type (see below). There
are other examples of new data types under the directories:
PG_CODE/contrib/chkpass/ ... an auto-encrypted password datatype
COMP9315 24T1 - Assignment 1
3/9
PG_CODE/contrib/citext/ ... a case-insensitive character string
datatype
PG_CODE/contrib/seg/ ... a confidence-interval datatype
These may or may not give you some useful ideas on how to implement the
PersonName data type. For example, many of these data types are fixed-size,
while PersonNames are variable-sized. A potentially useful example of
implementing variable-sized types can be found in:
PG_CODE/src/tutorial/funcs.c ... implementation of several data
types
Setting Up
You ought to start this assignment with a fresh copy of PostgreSQL, without
any changes that you might have made for the Prac exercises (unless these
changes are trivial). Note that you only need to configure, compile and install
your PostgreSQL server once for this assignment. All subsequent compilation
takes place in the src/tutorial directory, and only requires modification of
the files there.
Once you have re-installed your PostgreSQL server, you should run the
following commands:
$ cd PG_CODE/src/tutorial
$ cp complex.c pname.c
$ cp complex.source pname.source
Note the pname.* files will contain many references to complex; I do not want
to see any remaining occurences of the word complex in the files that you
eventually submit. These files simply provide a template in which you create
your PersonName type.
Once you've made the pname.* files, you should also edit the Makefile in this
directory and add the green text to the following lines:
MODULES = complex funcs pname
DATA_built = advanced.sql basics.sql complex.sql funcs.sql syscat.
The rest of the work for this assignment involves editing only the pname.c and
pname.source files. In order for the Makefile to work properly, you must use
the identifier _OBJWD_ in the pname.source file to refer to the directory holding
the compiled library. You should never modify directly the pname.sql file
produced by the Makefile. Place all of your C code in the pname.c file; do not
create any other *.c files.
Note that your submitted versions of pname.c and pname.source should not
contain any references to the complex type. Make sure that the documentation
COMP9315 24T1 - Assignment 1
4/9
(comments in program) describes the code that you wrote. Leaving the word
complex anywhere in either pname.* file will result in a 1 mark penalty.
The Person Name Data Type
We wish to define a new base type PersonName to represent people's names,
in the format FamilyName,GivenNames. We also aim to define a useful set of
operations on values of type PersonName and wish to be able to create indexes
on attributes of type PersonName. How you represent PersonName values
internally, and how you implement the functions to manipulate them internally,
is up to you. However, they must satisfy the requirements below.
Once implemented correctly, you should be able to use your PostgreSQL
server to build the following kind of SQL applications:
create table Students (
zid integer primary key,
name PersonName not null,
degree text,
-- etc. etc.
);
insert into Students(zid,name,degree) values
(9300035,'Shepherd, John Andrew', 'BSc(Computer Science)'),
(5012345,'Smith, Stephen', 'BE(Hons)(Software Engineering)');
create index on Students using hash (name);
select a.zid, a.name, b.zid
from Students a join Students b on (a.name = b.name);
select family(name), given(name), show(name)
from Students;
select name,count(*)
from Students
group by name;
Having defined a hash-based file structure, we would expect that the queries
would make use of it. You can check this by adding the keyword EXPLAIN
before the query, e.g.
db=# explain analyze select * from Students where name='Smith,John
which should, once you have correctly implemented the data type and loaded
sufficient data, show that an index-based scan of the data is being used. Note
that this will only be evident if you use a large amount of data (e.g. one of the
larger test data samples to be provided).
Person Name values
COMP9315 24T1 - Assignment 1
5/9
Valid PersonNames will have the above format with the following qualifications:
there may be a single space after the comma
there will be no people with just one name (e.g. no Prince, Jesus,
Aristotle, etc.)
there will be no numbers (e.g. noGates, William 3rd)
there will be no titles (e.g. no Dr, Prof, Mr, Ms)
there will be no initials (e.g. no Shepherd,John A)
In other words, you can ignore the possibility of certain types of names while
implementing your input and output functions.
If titles occur, you can assume that they will occur after a comma after the given
names, e.g. "Smith, John, Dr".
A more precise definition can be given using a BNF grammar:
PersonName ::= Family','Given | Family', 'Given
Family ::= NameList
Given ::= NameList
NameList ::= Name | Name' 'NameList
Name ::= Upper Letters
Letter ::= Upper | Lower | Punc
Letters ::= Letter | Letter Letters
Upper ::= 'A' | 'B' | ... | 'Z'
Lower ::= 'a' | 'b' | ... | 'z'
Punc ::= '-' | "'"
You should not make any assumptions about the maximum length of a
PersonName.
Under this syntax, the following are valid names:
Smith,John
Smith, John
O'Brien, Patrick Sean
Mahagedara Patabendige,Minosha Mitsuaki Senakasiri
I-Sun, Chen Wang
Clifton-Everest,Charles Edward
The following names are not valid in our system:
Jesus # no single-word names
Smith , Harold # space before the ","
Gates, William H., III # no initials, too many commas
A,B C # names must contain at least 2 letters
Smith, john # names begin with an upper-case letter
COMP9315 24T1 - Assignment 1
6/9
Think about why each of the above is invalid in terms of the syntax definition.
Important: for this assignment, we define an ordering on names as follows:
the ordering is determined initially by the ordering on the Family Name
if the Family Names are equal, then the ordering is determined by the
Given Names
ordering of parts is determined lexically
There are examples of how this works in the section on Operations on
PersonNames below.
Representing Person Names
The first thing you need to do is to decide on an internal representation for your
PersonName data type. You should do this, however, after you have looked at
the description of the operators below, since what they require may affect how
you decide to structure your internal PersonName values.
When you read strings representing PersonName values, they are converted
into your internal form, stored in the database in this form, and operations on
PersonName values are carried out using this data structure. It is useful to
define a canonical form for names, which may be slightly different to the form in
which they are read (e.g. "Smith, John" might be rendered as "Smith,John").
When you display PersonName values, you should show them in canonical
form, regardless of how they were entered or how they are stored.
The first functions you need to write are ones to read and display values of type
PersonName. You should write analogues of the functions complex_in(),
complex_out that are defined in the file complex.c. Call them, e.g.,
pname_in() and pname_out(). Make sure that you use the V1 style function
interface (as is done in complex.c).
Note that the two input/output functions should be complementary, meaning
that any string displayed by the output function must be able to be read using
the input function. There is no requirement for you to retain the precise string
that was used for input (e.g. you could store the PersonName value internally in
a different form such as splitting it into two strings: one for the family name(s),
and one for the given name(s)).
One thing that pname_in() must do is determine whether the name has the
correct structure (according to the grammar above). Your pname_out() should
display each name in a format that can be read by pname_in().
Note that you are not required to define binary input/output functions, called
receive_function and send_function in the PostgreSQL documentation,
and called complex_send and complex_recv in the complex.cfile.
COMP9315 24T1 - Assignment 1
7/9
As noted above, you cannot assume anything about the maximum length of
names. If your solution uses two fixed-size buffers (one for family, one for
given) then your mark is limited to a maximum of 8/15, even if you pass all of
the tests.
Operations on person names
You must implement all of the following operations for the PersonName type:
PersonName = PersonName ... two names are equal
Two PersonNames are equivalent if, they have the same family name(s)
and the same given name(s).
PersonName : Smith,John
PersonName : Smith, John
PersonName : Smith, John David
PersonName : Smith, James
(PersonName = PersonName ) is true
(PersonName = PersonName ) is true
(PersonName = PersonName ) is true (commutative)
(PersonName = PersonName ) is false
(PersonName = PersonName ) is false
PersonName > PersonName ... the first PersonName is greater than the
second
PersonName is greater than PersonName if the Family part of
PersonName is lexically greater than the Family part of PersonName . If
the Family parts are equal, then PersonName is greater than
PersonName if the Given part of PersonName is lexically greater than
the Given part of PersonName .
PersonName : Smith,James
PersonName : Smith,John
PersonName : Smith,John David
PersonName : Zimmerman, Trent
(PersonName > PersonName ) is false
(PersonName > PersonName ) is false
(PersonName > PersonName ) is true
(PersonName > PersonName ) is false
(PersonName > PersonName ) is true
Other operations: <>, >=, <, <=
You should also implement the above operations, whose semantics is
hopefully obvious from the descriptions above. The operators can typically
be implemented quite simply in terms of the first two operators.
family(PersonName) returns just the Family part of a name
COMP9315 24T1 - Assignment 1
8/9
PersonName : Smith,James
PersonName : O'Brien,Patrick Sean
PersonName : Mahagedara Patabendige,Minosha Mitsuaki Senakasir
PersonName : Clifton-Everest,David Ewan
family(PersonName ) returns "Smith"
family(PersonName ) returns "O'Brien"
family(PersonName ) returns "Mahagedara Patabendige"
family(PersonName ) returns "Clifton-Everest"
given(PersonName) returns just the Given part of a name
PersonName : Smith,James
PersonName : O'Brien,Patrick Sean
PersonName : Mahagedara Patabendige,Minosha Mitsuaki Senakasir
PersonName : Clifton-Everest,David Ewan
given(PersonName ) returns "James"
given(PersonName ) returns "Patrick Sean"
given(PersonName ) returns "Minosha Mitsuaki Senakasir"
given(PersonName ) returns "David Ewan"
show(PersonName) returns a displayable version of the name
It appends the entire Family name to the first Given name (everything
before the first space, if any), separated by a single space.
PersonName : Smith,James
PersonName : O'Brien,Patrick Sean
PersonName : Mahagedara Patabendige,Minosha Mitsuaki Senakasir
PersonName : Clifton-Everest,David Ewan
PersonName : Bronte,Greta-Anna Maryanne
show(PersonName ) returns "James Smith"
show(PersonName ) returns "Patrick O'Brien"
show(PersonName ) returns "Minosha Mahagedara Patabendige"
show(PersonName ) returns "David Clifton-Everest"
show(PersonName ) returns "Greta-Anna Bronte"
Hint: test out as many of your C functions as you can outside PostgreSQL (e.g.
write a simple test driver) before you try to install them in PostgreSQL. This will
make debugging much easier.
You should ensure that your definitions capture the full semantics of the
operators (e.g. specify commutativity if the operator is commutative). You
should also ensure that you provide sufficient definitions so that users of the
PersonName type can create hash-based indexes on an attribute of type
PersonName.
Submission
5
COMP9315 24T1 - Assignment 1
9/9
You need to submit two files: pname.c containing the C functions that
implement the internals of the PersonName data type, and pname.source
containing the template SQL commands to install the PersonName data type
into a PostgreSQL server. Do not submit the pname.sql file, since it contains
absolute file names which are not helpful in our test environment.
Have fun, jas
软件开发、广告设计客服
QQ:99515681
邮箱:99515681@qq.com
工作时间:8:00-23:00
微信:codinghelp
热点项目
更多
代写dts207tc、sql编程语言代做
2024-12-25
cs209a代做、java程序设计代写
2024-12-25
cs305程序代做、代写python程序...
2024-12-25
代写csc1001、代做python设计程...
2024-12-24
代写practice test preparatio...
2024-12-24
代写bre2031 – environmental...
2024-12-24
代写ece5550: applied kalman ...
2024-12-24
代做conmgnt 7049 – measurem...
2024-12-24
代写ece3700j introduction to...
2024-12-24
代做adad9311 designing the e...
2024-12-24
代做comp5618 - applied cyber...
2024-12-24
代做ece5550: applied kalman ...
2024-12-24
代做cp1402 assignment - netw...
2024-12-24
热点标签
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
联系我们
- QQ: 9951568
© 2021
www.rj363.com
软件定制开发网!