I am beginner with Ms Access and databases
I am building meeting management database. I am stuck at some point please help
Database purpose is to manage meetings with different firms which are in most cases reoccurs time to time
Table that I have created.
Table 1 - Firms
FirmID - AutoNo - PK
FirmName - Text
....
Table 2 - FirmReps (to store multiple reps of each firm)
FirmRepID - AutoNo
FirmID - FK
RepName - Text
...
Table 3 - Meeting Details (will be the main form)
MeetingID - AutoNo
MeetingDate - Date/Time
MeetingTime - Date/time
Venue - Text
FirmName - FK
...
I am looking for solution that when I enter meeting details and select the firm name all individuals will be shown in separate sub-form where I can select (tick) the interested reps for meeting
I have created a subform for FirmReps and link the master with FirmID but Every time I select the firm name all the reps are shown and not saved/linked with the meeting ID.
To get only the selected firm in the combobox on the subform, you can refer to the main form FirmID. Set the Row Source for the combo like so:
SELECT FirmRepID, RepName FROM FirmReps
WHERE FirmID = Forms!NameOfMeetingsFormHere!FirmID
Related
I’m creating an app that tracks attendance of players in amateur football teams. And I’m just not sure how to set up the database. A bit of info: every user has a team and should only see the events within his team per season.
These are the main things:
Users
Events
User stats (for later)
Events
Training / match / social
Date
Time
Subject / opponent
Attendance
Main questions:
Do I make an event table per team per season? Or do I put all events in one big table for every user?
What is the best way to handle the attendance? They should be able to choose from
Present
absent
Fan
Thanks in advance!
I would do it this way:
User
userid PK
Name
Team
teamid PK
TeamName
UserInTeam
userid FK
teamid FK
Event
eventid PK
home_teamid FK
visiting_teamid FK
eventtypeid FK
Date
Time
Subject / opponent
Attendance
Event type
eventtypeid PK
EventType
Attendance Type
attendanceid PK
AttendanceType
UserAtEvent
userid FK
eventid FK
attendancetypeid FK
Content of Event Type
1 Training
2 Match
3 Social
Content of Attendance Type
1 Present
2 Absent
3 Fan
For Event, home_teamid and visiting_teamid can be NULL if the event is not a match
The application will show the events based on the team the user is a member of.
I have created one sales cube which has country wise sales table and country table and security group table like below.
SALES TABLE:
country sales_amount
India 50000
UK 50000
NULL 50000
COUNTRY NAME:
country security_group_id
India S1
UK S2
SECURITY TABLE:
User_name security_group_id
ABC S1
XYZ S2
I am trying to restrict the data country wise,Here I got some issue what if country column has null value and how to handle row level security.
Here,Two users are unable to access data which has gl_country NULL.
How to handle in such that cases.
The NULL value of the country column in table SALES won't affect the execution of row level security.
Row level security restrict data based on which windows user loggs in and in our case the related condition columns are User_name and security_group_id.
For more details about Row level security, please refer:
Dynamic row level security with Analysis services tabular model
I have a table Hall which has structure like
CREATE TABLE Hall_tbl (
hall_id INTeger PRIMARY KEY AUTOINCREMENT NOT NULL,
name TEXT,
price INTEGER,
capacity INTEGER,
availibility INTEGER
);
Now, intention of the application is to make it work in a way that User looks at the calendar -> Selects a date -> If Hall is available on that particular day then User can interact with it else not.
So, it boils down to the point that Availibility is important and it should be reference to bunch of Dates. Once user open a particular date, he is presented with Time Slots. Depending on the Available Time Slots user can select the Hall. I am having hard time in getting idea how would it be possible to implement that.
First I thought to create a table called dates with columns date starting from 1-1-2018 to 1-1-2020 and create multiple time slot like 0-1 1-2 .. 2-24 and putting 0 to indicate they are not sold and I will change to 1 when User select an open Hall. But this will take me to create 365*4 rows and 25 columns which is not at all efficient. So how can I do this ?
Many application related to Ticket Booking, Flight booking have already implemented such stuff. So, How do they do it efficiently ??
Technology I am using is SQLITE
What you could do is have a table for the opening dates and add just the opening dates and then check if there is a row for the date if so then the hall is open otherwise it is not.
So based upon your Hall_tbl your could have :-
Your Hall_tbl
CREATE TABLE IF NOT EXISTS Hall_tbl (
hall_id INTEGER PRIMARY KEY,
name TEXT,
price INTEGER,
capacity INTEGER,
availibility INTEGER
);
AUTOINCREMENT isn't required and it is recommended to not use it unless necessary SQLite Autoincrement
availability column isn't required but has been left
Add some halls (4 id's 1-4)
INSERT INTO Hall_tbl (name, price, capacity, availibility)
VALUES('Grand Hall',200,50,0),
('Large Hall',100,25,0),
('Normal Hall',75,20,0),
('Small Hall',50,15,0);
The Hall opening times table
CREATE TABLE IF NOT EXISTS hall_opening_times (hall_reference, open_date);
Add some opening times (5)
INSERT INTO hall_opening_times
VALUES (1,'2018-04-23'), -- Grand hall open on 2018-04-23
(2,'2018-04-23'), -- Large Hall open on 2018-04-23
(2,'2018-04-25'), -- Large Hall open on 2018-04-25
(3,'2018-04-24'), -- Normal Hall open on 2018-04-24
(4,'2018-04-23'); -- Small Hall open on 2018-04-23
Checking if a hall is open
The following would return a single row with a single column where the value would be 0 (not open) or 1 (open) :-
This checks the Grand Hall for today (it's 2018-04-23 here)
SELECT count() > 0 AS hall_open FROM hall_opening_times WHERE hall_reference = 1 AND date(open_date) = date('now');
it returns 1 (in column hall_open) as the Grand Hall (ID = 1) is open on 2018-04-03 today (date('now'))
This one checks the Normal Hall for today
SELECT count() > 0 AS hall_open FROM hall_opening_times WHERE hall_reference = 3 AND date(open_date) = date('now');
it returns 0 (in column hall_open) as there are no entries for ID 3 on 2018-04-03
A little more
You could get a list of Open Halls using the following :-
SELECT group_concat(name,' - ') AS open_halls
FROM hall_opening_times JOIN Hall_tbl ON hall_reference = Hall_tbl.hall_id
WHERE open_date = date('now')
Which on 2018-04-23 would return (in column open_halls):-
Grand Hall - Large Hall - Small Hall
If the previous SQL were change to (to check tomorrow 2018-04-24) :-
SELECT group_concat(name,' - ') AS open_halls
FROM hall_opening_times JOIN Hall_tbl ON hall_reference = Hall_tbl.hall_id
WHERE open_date = date('now','+1 DAY')
Then it would return :-
Normal Hall
You could prune past open_times (if wanted) using something like :-
DELETE FROM hall_opening_times WHERE open_date < date('now','-1 WEEK');
will delete rows older than 1 week from the current date.
Note regarding date formats
The date format yyyy-MM-dd is one recognised/supported by SQLite date functions using that rather than d-M-yyyy can make things significantly simpler.
See - SQL As Understood By SQLite - Date And Time Functions
I'm trying to implement a feature whereby, apart from all the reports that I have in my system, I will allow the end user to create simple reports. (not overly complex reports that involves slicing and dicing across multiple tables with lots of logic)
The user will be able to:
1) Select a base table from a list of allowable tables (e.g., Customers)
2) Select multiple sub tables (e.g., Address table, with AddressId as the field to link Customers to Address)
3) Select the fields from the tables
4) Have basic sorting
Here's the database schema I have current, and I'm quite certain it's far from perfect, so I'm wondering what else I can improve on
AllowableTables table
This table will contain the list of tables that the user can create their custom reports against.
Id Table
----------------------------------
1 Customers
2 Address
3 Orders
4 Products
ReportTemplates table
Id Name MainTable
------------------------------------------------------------------
1 Customer Report #2 Customers
2 Customer Report #3 Customers
ReportTemplateSettings table
Id TemplateId TableName FieldName ColumnHeader ColumnWidth Sequence
-------------------------------------------------------------------------------
1 1 Customer Id Customer S/N 100 1
2 1 Customer Name Full Name 100 2
3 1 Address Address1 Address 1 100 3
I know this isn't complete, but this is what I've come up with so far. Does anyone have any links to a reference design, or have any inputs as to how I can improve this?
This needs a lot of work even though it’s relatively simple task. Here are several other columns you might want to include as well as some other details to take care of.
Store table name along with schema name or store schema name in additional column, add column for sorting and sort order
Create additional table to store child tables that will be used in the report (report id, schema name, table name, column in child table used to join tables, column in parent table used to join tables, join operator (may not be needed if it always =)
Create additional table that will store column names (report id, schema name, table name, column name, display as)
There are probably several more things that will come up after you complete this but hopefully this will get you in the right direction.
I have an existing application that has the following entities in the database
Customer
InvoiceGroup
SalesGroup
A customer can be part of multiple groups. Currently this is mapped in the following way
Customer table
- cid (Pk)
- fname
- surname
----
---
- invgrpdid (Fk)
- salesid (Fk)
Invoicegroup table
- invgrpid (Pk)
- name
- type
---
----
Salesgroup table
- salesid (Pk)
- name
- desc
-----
-----
I now have a requirement to add a new entity campaign. A Customer can be part of multiple campaigns. A campaign is deployed for a customer group which is created by
- selecting individual customers (custom) OR
- selecting an existing invoicegroup (invoice) OR
- selecting an existing salesgroup (sales)
The campaign customer list should be
- reusable, i.e can be used for multiple campaigns
- dynamic, i.e if created from an invoice/sales group, changes across the invoice and sales group
should be reflected to the campaign customer list
I am having difficulty designing for the dynamic requirement. I have come up with the following design, but it has exclusive arcs that is one key refering to multiple foreign keys which is not the recommended approach. I have thought of supertype and subtype, but I am not clear on designing the many-to-many relationships.
campaign
- campaignid(Pk)
- name
- startdate
- status
------
campaignlist
- listid(Pk)
- listname
- listtype - Invoice, Sales, Custom
- typeid (Fk) - Refers to invoicegroupid or salesgroupid depending on listtype
-----
customercampaign
- listid (Fk)
- customerid (Fk)
- status
- dateupdated
-------------
What would be a better approach to design this considering referential integrity and normalization.
The most frequent query run multiple times daily will be to retrieve all campaign information for a customer. So need to be mindful of multiple tables and joins.
At a first stab, I would do something like this:
CampaignList
- ID (PK)
- Name
CustomerCampaignList
- CampaignListID (FK to CampaignList.ID)
- CustomerID (FK)
UNIQUE (CampaignListID, CustomerID)
SalesGroupCampaignList
- CampaignListID (PK,FK to CampaignList.ID)
- SalesGroupID (FK)
UNIQUE (CampaignListID, SalesGroupID)
InvoiceGroupCampaignList
- CampaignListID (PK,FK to CampaignList.ID)
- InvoiceGroupID (FK)
UNIQUE (CampaignListID, InvoiceGroupID)
That is, use table inheritance. This is quite a normalised design, which in my opinion is the approach to take when you're not yet clued up on specific requirements. Optionally, you could make your life easier by denormalising a little and putting a CampaignListTypeID in the CampaignList table. In this case though, it would be difficult to maintain the integrity of the data model without writing logic in a trigger.
I'm assuming that you won't ever have to do interesting combination groups e.g., 2 x sales group + invoice group + a set of customers.