I want to create database where I will enter persons and to which project/program this person signed up.
For example:
Person: Max Stewart
- Project: Website
-- Program: What is website?
-- Program: How to create website?
-- Program: What do I need to create website?
Person: Roger Federer
- Project: Car
-- Program: Which car brand should I buy?
- Project: Website
-- Program: What is website?
And if I want to check which person joined to (Project: Website and Program: What is website) I'll get list:
- Max Stewart
- Roger Federer
This list would actually be a report in ms-access..
So far I've done this
I have 3 tables:
Person (PersonID, Person details...)
Project (ProjectID, ProjectName)
Program (ProgramID,PersonID, ProgramName, StartDate, EndDate)
Relationships:
Person -> (one-to-many) -> Program
Project -> (one-to-many) -> Program
Problem is that everytime I want to add another person to same program (program starts with new ID like this would be new program)
Any suggestion on this?
You can do that with a many to many relation.
Related
I am trying to self-teach myself database management using Murach books, and I found these exercises online but I don't know where to start with the last two. I am using the Alexamara Marina database to complete the following exercises.
Create a query that displays the following for all boats: (1 row)
Total number of boats (name it: number_of_boats),
the maximum rental fee (name it: highest_rental_fee),
the shortest boat (name it: shortest boat)
Modify exercise 3 (the one above) to display the same information by marina rather than as a total of all boats. (2 rows)
I appreciate any help or tips!
EDIT: I am not sure how to attach the Alexamara database file so I am pasting it on pastebin so that everyone can run and create it.(see below)
Alexamara
Yeah I was having trouble with the site letting me paste the link on its own... Sorry
i don't know the structure of the database you're working with, you could get it by using
SHOW COLUMNS FROM boats
i am assuming that the database name is 'boats' and it contains the columns 'fee' and 'length'
SELECT
COUNT(*) AS nuber_of_boats,
MAX(fee) AS highest_rental_fee,
MIN(length) AS shortest_boat
FROM boats;
I am assuming that a boat corresponds to the marina_slip table
Total number of boats (name it: number_of_boats)
SELECT
COUNT(*) AS number_of_boats,
MAX(RentalFee) AS highest_rental_fee,
MIN(Length) AS shorted_boat
from MarinaSlip
Modify exercise 3 (the one above) to display the same information by marina rather than as a total of all boats. (2 rows)
SELECT
COUNT(*) AS number_of_boats,
MAX(RentalFee) AS highest_rental_fee,
MIN(Length) AS shorted_boat,
MarinaNum
from MarinaSlip
group by MarinaNum
I am facing issue related to One to Many relation MySql Table.
Table: Employee {Columns: Code, Email, Supervisor(e.g. Code1, Code2, Code3), Hr1(Self-join with the employee), Hr1(Self-join with the employee)}
My Requirement is: We want to send birthday mail to all employees for the current date and that mail also we want to send employee supervisor and Hr with CC and BCC respectively.
So I want to create one view to fetch all the email ID linked with the employee just like the supervisor(BCC: Test#gmail.com) and HR(CC: Test#gmail.com).
So how to self-join the supervisor and Hr to achieve the Email Id in One row.
View ==> ViewEmployee : {Columns : EmployeeEmail, SupervisorEmail, HREmail }
So no need to fetch all the table field.
Please help me anyone know this.
Thanks
Sitansu
I have a csv records of sales, each record has column customer name. This column is a combination of persons name and organization name. How can I use spacy to detect if a this column is a person or organization?
This is a 'Named Entity Recognition' task. Spacy has a pretty good documentation:
doc = nlp(u'Apple is looking at buying U.K. startup for $1 billion')
for ent in doc.ents:
print(ent.text, ent.start_char, ent.end_char, ent.label_)
Apple 0 5 ORG
Thank you in advance for your help...
I want to get the parent site list/informatoin for a site based on its ID. There is a site hierarchy described in 2 tables, like this:
table: site
- id (PK)
- name
table: hierarchy
- siteid (PK) (siteid => site.id)
- parented (PK) (parented => site.id)
- topid (topid => site.id)
For example, you may have the following data in the tables:
site:
id,name
0,Earth
1,US
2,NY
3,GA
4,Queens
5,Farmers' Market
6,Buckhead
hierarchy:
siteid,parented,topid
5,4,1
4,2,1
2,1,1
1,0,1
5,6,1
6,3,1
3,1,1
1,0,1
I want to get all the parents of the Farmers's Market sites. There are markets in both Buckhead and Queens.
How do I make SQL walk / recurse up the tree to get something like this if I want the parent list for site id=5?:
site_name,parent_name
Farmers' Market,Queens
Queens,NY
NY,Earth
Farmers' Market,Buckhead
Buckhead,GA
GA,Earth
It occurs to me that there may need to be more than one row in the site table for Farmers' Market, but, I don't think so...
Thanks for your help,
David
While trying to use LINQ to SQL I encountered several problems.
I have table persons:
int ID
string firstName
string lastName
And table notes that has:
int ID
string noteText
string createdBy
datetime creationDate
int PersonID
PersonID is a foreign key and the relationship is 1:n
I tried to use LINQ to SQL to create a person and some notes for each person.
Person person = new person();
Person.firstName = "me";
Person.note = new note();
Person.note.noteText = "some text…";
_DataContext.Persons.InsertOnSubmit(person);
_DataContext.SubmitChanges();
The problem is that the person object doesn't yet exist in the DB so it doesn't have an ID yet. So the note.personID filed has a 0 value… (the ID field is an identity field in the sql server)
The only solution for this that I found is to create a person , submitchanges and then create a note and submitchanges again.
Am I missing something here or maybe that’s the way one should work with LINQ to SQL?
How can I add multiple notes per person with LTS? I have a 1:n relationship and I don't see it with LTS.
If a person has 10000 notes, I don't want the person object constructor to load all the notes he has. I want to load them only when I refer to them. How can I config LTS to load the notes on demand?
If you aren't using the LinqToSql class designer, you should think about using it. The classes it generates will support the insertion scenario you outlined.
I can tell you aren't using the designer because it would give you a Notes (plural) property on the Person... as Person is 1 to Many with Notes.
How can I config LTS to load the notes on demand?
The designer will generate a property of type EntitySet(Note), which will load Notes on demand.